unknown property 'optimization'

1804 views webpack

I'll trying to use uglify with webpack but got this error:

Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
 - configuration has an unknown property 'optimization'. These properties are valid:
   object { amd?, bail?, cache?, context?, dependencies?, devServer?, devtool?, entry, externals?, loader?, module?, name?, node?, output?, performance?, plugins?, profile?, recordsInputPath?, recordsOutputPath?, recordsPath?, resolve?, resolveLoader?, stats?, target?, watch?, watchOptions? }

I have

const UglifyJsPlugin = require('uglifyjs-webpack-plugin');


optimization: {
        minimizer: [new UglifyJsPlugin()]

in my webpack.config.js, looks like webpack is not recognizing 'optimization'?

answered question

1 Answer


Perhaps you are using an old webpack version (3?) and you might need to put the plug-in instance in the plugin property:

module.exports = {
    plugins: [new UglifyJSPlugin()]

Always try to find documentation matching the version you are using or update webpack to a newer version. The current version is 4.19.0 (at 2018-09-17).

posted this

Have an answer?


Please login first before posting an answer.