webpack.config.prod.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. module.exports = merge(baseConfig, {
  8. mode: 'production',
  9. optimization: {
  10. minimizer: [
  11. new UglifyJSPlugin({
  12. uglifyOptions: {
  13. // Eliminate comments
  14. comments: false,
  15. compress: {
  16. // remove warnings
  17. warnings: false,
  18. // Drop console statements
  19. drop_console: true,
  20. }
  21. }
  22. })
  23. ]
  24. // splitChunks: {
  25. // cacheGroups: {
  26. // commons: {
  27. // test: /[\\/]node_modules[\\/]/,
  28. // name: "vendor",
  29. // chunks: "all",
  30. // },
  31. // },
  32. // },
  33. },
  34. module: {
  35. rules: [
  36. {
  37. test: /\.css?$/,
  38. use: [
  39. MiniCssExtractPlugin.loader,
  40. 'css-loader'
  41. ]
  42. }, {
  43. test: /\.scss?$/,
  44. use: [
  45. MiniCssExtractPlugin.loader,
  46. 'css-loader',
  47. 'sass-loader'
  48. ]
  49. }
  50. ]
  51. },
  52. plugins: [
  53. // new MiniCssExtractPlugin({
  54. // filename: 'main.css'
  55. // })
  56. ]
  57. })