webpack.config.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. process.traceDeprecation = true;
  24. const config = {
  25. devtool: false,
  26. entry: {
  27. hue: { import: './desktop/core/src/desktop/js/hue.js' },
  28. editor: { import: './desktop/core/src/desktop/js/apps/editor/app.js', dependOn: 'hue' },
  29. notebook: { import: './desktop/core/src/desktop/js/apps/notebook/app.js', dependOn: 'hue' },
  30. tableBrowser: {
  31. import: './desktop/core/src/desktop/js/apps/tableBrowser/app.js',
  32. dependOn: 'hue'
  33. },
  34. jobBrowser: { import: './desktop/core/src/desktop/js/apps/jobBrowser/app.js', dependOn: 'hue' }
  35. },
  36. mode: 'development',
  37. module: {
  38. rules: [
  39. {
  40. test: /\.vue$/,
  41. use: 'vue-loader'
  42. },
  43. {
  44. test: /\.tsx?$/,
  45. exclude: /node_modules/,
  46. loader: 'babel-loader'
  47. },
  48. { test: /\.js$/, use: ['source-map-loader'], enforce: 'pre' },
  49. {
  50. test: /\.(html)$/,
  51. use: [{ loader: 'html', options: { interpolater: true, removeComments: false } }]
  52. },
  53. { test: /\.less$/, use: ['style-loader', 'css-loader', 'less-loader'] },
  54. { test: /\.s[ac]ss$/, use: ['style-loader', 'css-loader', 'sass-loader'] },
  55. { test: /\.css$/, use: ['style-loader', 'css-loader'] },
  56. { test: /\.(woff2?|ttf|eot|svg)$/, use: ['file-loader'] },
  57. {
  58. test: /\.jsx?$/,
  59. exclude: /node_modules/,
  60. use: ['babel-loader']
  61. }
  62. ]
  63. },
  64. optimization: {
  65. //minimize: true,
  66. minimize: false,
  67. splitChunks: {
  68. chunks: 'all',
  69. name: splitChunksName,
  70. maxSize: 1000000,
  71. hidePathInfo: true
  72. }
  73. },
  74. output: {
  75. path: __dirname + '/desktop/core/src/desktop/static/desktop/js/bundles/hue',
  76. filename: '[name]-bundle-[fullhash].js',
  77. chunkFilename: '[name]-chunk-[fullhash].js',
  78. clean: true
  79. },
  80. performance: {
  81. maxEntrypointSize: 400 * 1024, // 400kb
  82. maxAssetSize: 400 * 1024 // 400kb
  83. },
  84. plugins: getPluginConfig(BUNDLES.HUE).concat([
  85. new CleanWebpackPlugin([`${__dirname}/desktop/core/src/desktop/static/desktop/js/bundles/hue`])
  86. ]),
  87. resolve: {
  88. extensions: ['.json', '.jsx', '.js', '.tsx', '.ts', '.vue'],
  89. modules: ['node_modules', 'js'],
  90. alias: {
  91. bootstrap: __dirname + '/node_modules/bootstrap-2.3.2/js',
  92. vue$: __dirname + '/node_modules/vue/dist/vue.esm-browser.prod.js'
  93. }
  94. }
  95. };
  96. // To customize build configurations
  97. const EXTEND_CONFIG_FILE = './webpack.config.extend.js';
  98. if (fs.existsSync(EXTEND_CONFIG_FILE)) {
  99. const endedConfig = require(EXTEND_CONFIG_FILE);
  100. endedConfig(config);
  101. console.info('Webpack extended!');
  102. }
  103. module.exports = config;