You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
1.3 KiB

  1. // Note: You must restart bin/webpack-dev-server for changes to take effect
  2. /* eslint global-require: 0 */
  3. const webpack = require('webpack');
  4. const merge = require('webpack-merge');
  5. const CompressionPlugin = require('compression-webpack-plugin');
  6. const sharedConfig = require('./shared.js');
  7. const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
  8. module.exports = merge(sharedConfig, {
  9. devtool: 'source-map', // separate sourcemap file, suitable for production
  10. output: { filename: '[name]-[chunkhash].js' },
  11. plugins: [
  12. new webpack.optimize.UglifyJsPlugin({
  13. compress: true,
  14. mangle: true,
  15. output: {
  16. comments: false,
  17. },
  18. sourceMap: true,
  19. }),
  20. new CompressionPlugin({
  21. asset: '[path].gz[query]',
  22. algorithm: 'gzip',
  23. test: /\.(js|css|svg|eot|ttf|woff|woff2)$/,
  24. }),
  25. new BundleAnalyzerPlugin({ // generates report.html and stats.json
  26. analyzerMode: 'static',
  27. generateStatsFile: true,
  28. statsOptions: {
  29. // allows usage with http://chrisbateman.github.io/webpack-visualizer/
  30. chunkModules: true,
  31. },
  32. openAnalyzer: false,
  33. logLevel: 'silent', // do not bother Webpacker, who runs with --json and parses stdout
  34. }),
  35. ],
  36. });