webpack.config.prod.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. parallel: true,
  42. test: /\.(js|vue)$/,
  43. // extractComments: true
  44. terserOptions: {
  45. compress: {
  46. // drop_console: true,
  47. pure_funcs: [
  48. 'console.log',
  49. 'console.info',
  50. 'console.debug'
  51. // 'console.warn'
  52. ]
  53. },
  54. },
  55. })
  56. ],
  57. },
  58. plugins: [
  59. new webpack.DefinePlugin({
  60. 'process.env.NODE_ENV': JSON.stringify('production')
  61. })
  62. ]
  63. })