webpack.config.js 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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 CleanWebpackPlugin = require('clean-webpack-plugin');
  17. const {
  18. BUNDLES,
  19. getPluginConfig,
  20. splitChunksName
  21. } = require('./desktop/core/src/desktop/js/webpack/configUtils');
  22. module.exports = {
  23. devtool: false,
  24. entry: {
  25. hue: ['./desktop/core/src/desktop/js/hue.js'],
  26. notebook: ['./desktop/core/src/desktop/js/apps/notebook/app.js'],
  27. tableBrowser: ['./desktop/core/src/desktop/js/apps/tableBrowser/app.js'],
  28. jobBrowser: ['./desktop/core/src/desktop/js/apps/jobBrowser/app.js']
  29. },
  30. mode: 'development',
  31. module: {
  32. rules: [
  33. {
  34. test: /\.tsx?$/,
  35. exclude: /node_modules/,
  36. loader: 'babel-loader'
  37. },
  38. { test: /\.js$/, use: ['source-map-loader'], enforce: 'pre' },
  39. { test: /\.(html)$/, loader: 'html?interpolate&removeComments=false' },
  40. { test: /\.less$/, loader: 'style-loader!css-loader!less-loader' },
  41. { test: /\.s[ac]ss$/, loader: 'style-loader!css-loader!sass-loader' },
  42. { test: /\.css$/, loader: 'style-loader!css-loader' },
  43. { test: /\.(woff2?|ttf|eot|svg)$/, loader: 'file-loader' },
  44. {
  45. test: /\.jsx?$/,
  46. exclude: /node_modules/,
  47. loader: 'babel-loader'
  48. },
  49. {
  50. test: /\.vue$/,
  51. loader: 'vue-loader',
  52. options: {
  53. shadowMode: true,
  54. loaders: {
  55. less: ['vue-style-loader', 'css-loader', 'less-loader', 'sass-loader']
  56. }
  57. }
  58. }
  59. ]
  60. },
  61. optimization: {
  62. //minimize: true,
  63. minimize: false,
  64. splitChunks: {
  65. chunks: 'all',
  66. name: splitChunksName
  67. },
  68. runtimeChunk: {
  69. name: 'hue'
  70. }
  71. },
  72. output: {
  73. path: __dirname + '/desktop/core/src/desktop/static/desktop/js/bundles/hue',
  74. filename: '[name]-bundle-[hash].js',
  75. chunkFilename: '[name]-chunk-[hash].js'
  76. },
  77. performance: {
  78. maxEntrypointSize: 400 * 1024, // 400kb
  79. maxAssetSize: 400 * 1024 // 400kb
  80. },
  81. plugins: getPluginConfig(BUNDLES.HUE).concat([
  82. new CleanWebpackPlugin([`${__dirname}/desktop/core/src/desktop/static/desktop/js/bundles/hue`])
  83. ]),
  84. resolve: {
  85. extensions: ['.json', '.jsx', '.js', '.tsx', '.ts', '.vue'],
  86. modules: ['node_modules', 'js'],
  87. alias: {
  88. bootstrap: __dirname + '/node_modules/bootstrap-2.3.2/js',
  89. vue$: __dirname + '/node_modules/vue/dist/vue.esm.browser.min.js'
  90. }
  91. }
  92. };