While running in production mode, if terser is set to false an error is thrown.
webpack.mix.js:require('laravel-mix')
.options({ terser: false })
.js('resources/assets/js/app.js', 'public/js');
webpack.mix.js fileyarn build -pubuntu@ubuntu-bionic:/var/www/xxxx$ yarn build -p
yarn run v1.13.0
$ node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js -p
Terser Plugin Invalid Options
options should be object
ValidationError: Terser Plugin Invalid Options
at validateOptions (/vagrant/node_modules/schema-utils/src/validateOptions.js:32:11)
at new TerserPlugin (/vagrant/node_modules/terser-webpack-plugin/dist/index.js:40:30)
at module.exports (/vagrant/node_modules/laravel-mix/src/builder/webpack-default.js:41:23)
at new WebpackConfig (/vagrant/node_modules/laravel-mix/src/builder/WebpackConfig.js:14:30)
at Object.<anonymous> (/vagrant/node_modules/laravel-mix/setup/webpack.config.js:29:18)
at Module._compile (/vagrant/node_modules/v8-compile-cache/v8-compile-cache.js:178:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:732:10)
at Module.load (internal/modules/cjs/loader.js:620:32)
at tryModuleLoad (internal/modules/cjs/loader.js:560:12)
at Function.Module._load (internal/modules/cjs/loader.js:552:3)
at Module.require (internal/modules/cjs/loader.js:657:17)
at require (/vagrant/node_modules/v8-compile-cache/v8-compile-cache.js:159:20)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Also worth noting that you can't enable it in development mode either.
Why would someone wants to disable to js minification in production?
I personally ran into this situation trying to debug a problem that only occurred while compiling for production. It would have been very helpful to be able to disable terser to narrow down what could be causing the issue, so I had to manually modify the laravel-mix source files temporarily.
That being said, I'm sure there are other cases where one would want to disable it in production - maybe in a case where sourcemaps aren't working 100% and you need a more helpful error log.
Did you try this?
terser: {
terserOptions: {
compress: false
}
}
also, maybe mix.sourceMaps() will help you?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
You can disable minification in Laravel Mix like so:
mix.webpackConfig({
optimization: {
minimize: false,
}
});
Most helpful comment
Did you try this?
also, maybe mix.sourceMaps() will help you?