[Vuejs]-Vue SPA and webpack โ€“ minify and mangle index.html

0๐Ÿ‘

โœ…

I added this to my vue.config.js

module.exports = {
    chainWebpack: config => {
        config
            .plugin('html')
            .tap(args => {
                if (process.env.NODE_ENV === 'production')
                    args[0].minify = {
                        minifyCSS: true,
                        minifyJS: true,
                        minifyURLs: true,
                        removeComments: true,
                        collapseWhitespace: true,
                        collapseBooleanAttributes: true,
                        removeScriptTypeAttributes: true,
                        removeAttributeQuotes: true,
                        removeEmptyAttributes: true,
                        removeStyleLinkTypeAttributes: true
                    };
                return args;
            })
    },
    ...  // Other configs
}

More details here

Leave a comment