Home

Issue: 621

Way to minify all bundle js files?

[issue link]

Hi,

I’m looking for a way to minify all bunfle js files on build. I couldn’t figure what I’m missing here.

Here’s an example of what I tried (here with babili):

build: {
	extend (config, { isDev, isClient }) {
		if (!isDev) {
			config.devtool = false
			config.plugins.push(
				new BabiliPlugin({
					// options here
				}, {
					comments: false
				})
			)
		}
	}
}

The build is correctly made, but has no effect on the bundles files. Another try with uglifyjs:

build: {
	extend (config, { isDev, isClient }) {
		if (!isDev) {
			config.devtool = false
			config.plugins.push(
				new webpack.optimize.UglifyJsPlugin({
					parse: {
						strict: true
					},
					compress: {
						unsafe: true,
						warnings: false,
						drop_console:true
					},
					output: {
						comments: false,
						ascii_only: true
					},
					mangle: true
				})
			)
		}
	}
}

This is globally the last thing I need to get a good grade on PageSpeed: https://gtmetrix.com/reports/dev.emmanuelbeziat.com/OpP40maF

If anybody has a working example, it would surely help 😃 Thanks!

This question is available on Nuxt.js community (#c537)