webpack.config.prod.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. // minimizer: [
  16. // new UglifyJSPlugin({
  17. // uglifyOptions: {
  18. // // Eliminate comments
  19. // comments: false,
  20. // // remove warnings
  21. // warnings: false,
  22. // minimize: false,
  23. // mangle: false,
  24. // compress: {
  25. // // Drop console statements
  26. // drop_console: true,
  27. // }
  28. // }
  29. // })
  30. // ],
  31. splitChunks: {
  32. cacheGroups: {
  33. commons: {
  34. test: /[\\/]node_modules[\\/]/,
  35. name: "vendor",
  36. chunks: "all",
  37. }
  38. }
  39. }
  40. },
  41. module: {
  42. rules: [
  43. {
  44. test: /\.css?$/,
  45. use: [
  46. MiniCssExtractPlugin.loader,
  47. 'css-loader'
  48. ]
  49. }, {
  50. test: /\.scss$/,
  51. use: [
  52. MiniCssExtractPlugin.loader,
  53. 'css-loader',
  54. 'sass-loader'
  55. ]
  56. }
  57. ]
  58. },
  59. plugins: [
  60. new MiniCssExtractPlugin({
  61. filename: 'main.css'
  62. }),
  63. new webpack.DefinePlugin({
  64. "process.env": "'prod'"
  65. })
  66. ]
  67. })