webpack.config.prod.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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 TerserPlugin = require("terser-webpack-plugin");
  7. module.exports = merge(baseConfig, {
  8. mode: 'production',
  9. module: {
  10. rules: [
  11. {
  12. test: /\.css?$/,
  13. use: [
  14. MiniCssExtractPlugin.loader,
  15. 'css-loader'
  16. ]
  17. }, {
  18. test: /\.scss?$/,
  19. use: [
  20. MiniCssExtractPlugin.loader,
  21. 'css-loader',
  22. 'sass-loader'
  23. ]
  24. }, {
  25. test: /\.(png|jpg|gif)$/,
  26. use: [
  27. {
  28. loader: 'url-loader',
  29. options: {
  30. limit: 5000
  31. }
  32. }
  33. ]
  34. }
  35. ]
  36. },
  37. optimization: {
  38. minimize: true,
  39. minimizer: [
  40. new TerserPlugin({
  41. sourceMap: true, // Must be set to true if using source-maps in production
  42. parallel: true,
  43. test: /\.(js|vue)$/,
  44. // extractComments: true
  45. terserOptions: {
  46. compress: {
  47. drop_console: true,
  48. },
  49. },
  50. })
  51. ],
  52. },
  53. // ,
  54. // plugins: []
  55. })