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.

43 lines
1.3 KiB

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