Error- clean-webpack-plugin only accepts an options object

Viewed 744

Whenever I try to push my code to heroku receiving this error. Any solution?

 new CleanWebpackPlugin(['dist'], {
  root: path.resolve(__dirname, '..'),
  exclude: '.gitignore'
})

Error: clean-webpack-plugin only accepts an options object. See:

remote: https://github.com/johnagan/clean-webpack-plugin#options-and- 
defaults-optional

remote: at new CleanWebpackPlugin 
(/tmp/build_292ba470efc2cc3ad6c89a8c22c708c9/node_modules/clean-webpack- 
plugin/dist/clean-webpack-plugin.js:17:13)

remote: at Object.<anonymous> 
(/tmp/build_292ba470efc2cc3ad6c89a8c22c708c9/webpack/prod.config.js:90:5)

remote:  at Module._compile 
(/tmp/build_292ba470efc2cc3ad6c89a8c22c708c9/node_modules/v8-compile- 
cache/v8-compile-cache.js:192:30)

remote:at Object.Module._extensions..js (internal/modules/cjs/loader.js:7
1 Answers

It looks like you are using old config with newer plugin version. Check the upgrade information:

If using basic config new CleanWebpackPlugin(['dist']), simply remove ['dist'] and everything will work as expected. Otherwise read carefully below.

Related