webpack.config.prod.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. // remove warnings
  16. warnings: false,
  17. compress: {
  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. test: /\.(png|jpg|gif)$/,
  51. use: [
  52. {
  53. loader: 'url-loader',
  54. options: {
  55. limit: 5000
  56. }
  57. }
  58. ]
  59. }
  60. ]
  61. },
  62. plugins: [
  63. // new MiniCssExtractPlugin({
  64. // filename: 'main.css'
  65. // })
  66. ]
  67. })