webpack.config.prod.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. 'use strict'
  2. const webpack = require('webpack')
  3. const merge = require('webpack-merge')
  4. const baseConfig = require('./webpack.config.base')
  5. const MiniCssExtractPlugin = require('mini-css-extract-plugin')
  6. const UglifyJSPlugin = require('uglifyjs-webpack-plugin')
  7. // ERROR in vendor.js from UglifyJs
  8. // RangeError: Maximum call stack size exceeded
  9. module.exports = merge(baseConfig, {
  10. mode: 'production',
  11. output: {
  12. publicPath: '/'
  13. },
  14. optimization: {
  15. minimize: true,
  16. minimizer: [
  17. new UglifyJSPlugin({
  18. uglifyOptions: {
  19. // Eliminate comments
  20. comments: false,
  21. // remove warnings
  22. // warnings: false,
  23. minimize: false,
  24. mangle: false,
  25. compress: {
  26. // Drop console statements
  27. drop_console: true,
  28. }
  29. }
  30. })
  31. ],
  32. splitChunks: {
  33. cacheGroups: {
  34. commons: {
  35. test: /[\\/]node_modules[\\/]/,
  36. name: "vendor",
  37. chunks: "all",
  38. }
  39. }
  40. }
  41. },
  42. module: {
  43. rules: [
  44. {
  45. test: /\.css?$/,
  46. use: [
  47. MiniCssExtractPlugin.loader,
  48. 'css-loader'
  49. ]
  50. }, {
  51. test: /\.scss$/,
  52. use: [
  53. MiniCssExtractPlugin.loader,
  54. 'css-loader',
  55. 'sass-loader'
  56. ]
  57. }
  58. ]
  59. },
  60. plugins: [
  61. new MiniCssExtractPlugin({
  62. filename: 'main.css'
  63. }),
  64. new webpack.DefinePlugin({
  65. "process.env": "'prod'"
  66. })
  67. ]
  68. })