1. const { resolve } = require('path');
    2. const HtmlWebpackPlugin = require('html-webpack-plugin');
    3. module.exports = {
    4. entry: './src/js/index.js',
    5. output: {
    6. filename: 'js/built.js',
    7. path: resolve(__dirname, 'build')
    8. },
    9. plugins: [
    10. new HtmlWebpackPlugin({
    11. template: './src/index.html',
    12. // 压缩html代码
    13. minify: {
    14. // 移除空格
    15. collapseWhitespace: true,
    16. // 移除注释
    17. removeComments: true
    18. }
    19. })
    20. ],
    21. mode: 'production'
    22. };