I tried to implement a webpack config on a Wordpress theme. I want to add the CleanWebpackPlugin and made a correct install of it.
I read a tutorial and I wrote something like this on my webpack.config.js:
new CleanWebpackPlugin(['./js/build/*','./css/build/*']),
After I made my npm run build
I received this error:
clean-webpack-plugin only accepts an options object.
and it redirected me to the GitHub project. I read the documentation but didn't find how to solve my problem.
Can somebody help?
I see that CleanWebpackPlugin v2 was released 18 days ago, It looks like you are using an old option type.
The new version, claims:
By default, this plugin will remove all files inside webpack's output.path directory, as well as all unused webpack assets after every successful rebuild.
So, if you need to clean a folder that is not in the output.path
, you probably should follow: additional v2 information.
They introduced a new option to clean paths that are outside of output.path
:
new CleanWebpackPlugin({
cleanOnceBeforeBuildPatterns: ['./js/build/*','./css/build/*']
})