webpack.config.js 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. var webpack = require('webpack');
  2. var BundleTracker = require('webpack-bundle-tracker');
  3. var WebpackShellPlugin = require('webpack-shell-plugin');
  4. new webpack.ProvidePlugin({
  5. $: 'jquery',
  6. jQuery: 'jquery',
  7. 'window.jQuery': 'jquery'
  8. });
  9. module.exports = {
  10. devtool: 'source-map',
  11. mode: 'development',
  12. optimization: {
  13. minimize: true
  14. },
  15. performance: {
  16. maxEntrypointSize: 400 * 1024, // 400kb
  17. maxAssetSize: 400 * 1024 // 400kb
  18. },
  19. resolve: {
  20. extensions: ['.json', '.jsx', '.js'],
  21. modules: [
  22. 'node_modules',
  23. 'js'
  24. ],
  25. alias: {
  26. bootstrap: 'bootstrap/js',
  27. 'cloudera-ui': 'cui',
  28. _: 'lodash',
  29. komapping: 'knockout.mapping',
  30. 'query-command-supported': 'query-command-supported/src/queryCommandSupported',
  31. pubsub: 'pubsub.js/pubsub',
  32. }
  33. },
  34. entry: {
  35. hue: ['./desktop/core/src/desktop/js/hue.js']
  36. },
  37. output: {
  38. path: __dirname + '/desktop/core/src/desktop/static/desktop/js',
  39. filename: 'hue-bundle-[hash].js'
  40. },
  41. module: {
  42. rules: [
  43. { test: /\.(html)$/, loader: 'html?interpolate&removeComments=false' },
  44. { test: /\.less$/, loader: 'style-loader!css-loader!less-loader' },
  45. { test: /\.css$/, loader: 'style-loader!css-loader' },
  46. { test: /\.(woff2?|ttf|eot|svg)$/, loader: 'file-loader' },
  47. {
  48. test: /\.jsx?$/,
  49. exclude: /node_modules/,
  50. loader: 'babel-loader'
  51. },
  52. // expose lodash and jquery for knockout templates to access
  53. { test: /lodash$/, loader: 'expose-loader?_' },
  54. { test: /jquery/, loader: 'expose-loader?$!expose-loader?jQuery' },
  55. // needed for moment-timezone
  56. { include: /\.json$/, loaders: ['json-loader'] }
  57. ]
  58. },
  59. plugins: [
  60. new WebpackShellPlugin({ onBuildStart:[__dirname + '/tools/scripts/clean_js_bundles.sh ' + __dirname ] }),
  61. new BundleTracker({ filename: './webpack-stats.json' }),
  62. new webpack.BannerPlugin('\nLicensed to Cloudera, Inc. under one\nor more contributor license agreements. See the NOTICE file\ndistributed with this work for additional information\nregarding copyright ownership. Cloudera, Inc. licenses this file\nto you under the Apache License, Version 2.0 (the\n"License"); you may not use this file except in compliance\nwith the License. You may obtain a copy of the License at\n\nhttp://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an "AS IS" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n'),
  63. ]
  64. };