1. const TerserPlugin = require("terser-webpack-plugin")
    2. module.exports = {
    3. mode: 'production',
    4. optimization: {
    5. minimize: true, // 启用 minimizer
    6. minimizer: [
    7. new CssMinimizerPlugin(),
    8. new TerserPlugin({
    9. extractComments: false // 不生成LICENSE
    10. })
    11. ]
    12. },
    13. plugins: [
    14. new CleanWebpackPlugin(),
    15. new CopyWebpackPlugin({
    16. patterns: [
    17. {
    18. from: 'public',
    19. globOptions: {
    20. ignore: ['**/index.html']
    21. }
    22. }
    23. ]
    24. }),
    25. new MiniCssExtractPlugin({
    26. filename: 'css/[name].[hash:8].css'
    27. })
    28. ]
    29. }