webpack.config.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. // Licensed to Cloudera, Inc. under one
  2. // or more contributor license agreements. See the NOTICE file
  3. // distributed with this work for additional information
  4. // regarding copyright ownership. Cloudera, Inc. licenses this file
  5. // to you under the Apache License, Version 2.0 (the
  6. // "License"); you may not use this file except in compliance
  7. // with the License. You may obtain a copy of the License at
  8. //
  9. // http://www.apache.org/licenses/LICENSE-2.0
  10. //
  11. // Unless required by applicable law or agreed to in writing, software
  12. // distributed under the License is distributed on an "AS IS" BASIS,
  13. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. // See the License for the specific language governing permissions and
  15. // limitations under the License.
  16. const fs = require('fs');
  17. const CleanWebpackPlugin = require('clean-webpack-plugin');
  18. const {
  19. BUNDLES,
  20. getPluginConfig,
  21. splitChunksName
  22. } = require('./desktop/core/src/desktop/js/webpack/configUtils');
  23. const config = {
  24. devtool: false,
  25. entry: {
  26. hue: ['./desktop/core/src/desktop/js/hue.js'],
  27. editor: ['./desktop/core/src/desktop/js/apps/editor/app.js'],
  28. notebook: ['./desktop/core/src/desktop/js/apps/notebook/app.js'],
  29. tableBrowser: ['./desktop/core/src/desktop/js/apps/tableBrowser/app.js'],
  30. jobBrowser: ['./desktop/core/src/desktop/js/apps/jobBrowser/app.js']
  31. },
  32. mode: 'development',
  33. module: {
  34. rules: [
  35. {
  36. test: /\.tsx?$/,
  37. exclude: /node_modules/,
  38. loader: 'babel-loader'
  39. },
  40. { test: /\.js$/, use: ['source-map-loader'], enforce: 'pre' },
  41. { test: /\.(html)$/, loader: 'html?interpolate&removeComments=false' },
  42. { test: /\.less$/, loader: 'style-loader!css-loader!less-loader' },
  43. { test: /\.s[ac]ss$/, loader: 'style-loader!css-loader!sass-loader' },
  44. { test: /\.css$/, loader: 'style-loader!css-loader' },
  45. { test: /\.(woff2?|ttf|eot|svg)$/, loader: 'file-loader' },
  46. {
  47. test: /\.jsx?$/,
  48. exclude: /node_modules/,
  49. loader: 'babel-loader'
  50. },
  51. {
  52. test: /\.vue$/,
  53. loader: 'vue-loader',
  54. options: {
  55. shadowMode: true,
  56. loaders: {
  57. less: ['css-loader', 'less-loader', 'sass-loader']
  58. }
  59. }
  60. }
  61. ]
  62. },
  63. optimization: {
  64. //minimize: true,
  65. minimize: false,
  66. splitChunks: {
  67. chunks: 'all',
  68. name: splitChunksName,
  69. maxSize: 1000000,
  70. hidePathInfo: true
  71. },
  72. runtimeChunk: {
  73. name: 'hue'
  74. }
  75. },
  76. output: {
  77. path: __dirname + '/desktop/core/src/desktop/static/desktop/js/bundles/hue',
  78. filename: '[name]-bundle-[hash].js',
  79. chunkFilename: '[name]-chunk-[hash].js'
  80. },
  81. performance: {
  82. maxEntrypointSize: 400 * 1024, // 400kb
  83. maxAssetSize: 400 * 1024 // 400kb
  84. },
  85. plugins: getPluginConfig(BUNDLES.HUE).concat([
  86. new CleanWebpackPlugin([`${__dirname}/desktop/core/src/desktop/static/desktop/js/bundles/hue`])
  87. ]),
  88. resolve: {
  89. extensions: ['.json', '.jsx', '.js', '.tsx', '.ts', '.vue'],
  90. modules: ['node_modules', 'js'],
  91. alias: {
  92. bootstrap: __dirname + '/node_modules/bootstrap-2.3.2/js',
  93. vue$: __dirname + '/node_modules/vue/dist/vue.esm-browser.prod.js'
  94. }
  95. }
  96. };
  97. // To customize build configurations
  98. const EXTEND_CONFIG_FILE = './webpack.config.extend.js';
  99. if (fs.existsSync(EXTEND_CONFIG_FILE)) {
  100. const endedConfig = require(EXTEND_CONFIG_FILE);
  101. endedConfig(config);
  102. console.info('Webpack extended!');
  103. }
  104. module.exports = config;