Closed pgnd closed 4 years ago
Since v3 we’ve moved to a named export. Try:
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
chaging my existing, previously working config
- const CleanWebpackPlugin = require('clean-webpack-plugin');
+ const { CleanWebpackPlugin } = require('clean-webpack-plugin');
exports.clean = path => ({
plugins: [
new CleanWebpackPlugin(
path,
{
dry: false,
verbose: true,
watch: false,
exclude: [],
allowExternal: false,
beforeEmit: false
}
)
],
});
and clears the constructor error.
but, now returns,
Error: clean-webpack-plugin only accepts an options object. See:
https://github.com/johnagan/clean-webpack-plugin#options-and-defaults-optional
1st, just fyi, THAT^^ tag is incorrect; should be
https://github.com/johnagan/clean-webpack-plugin#user-content-options-and-defaults-optional
What's the correct usage now for the options object? If I've missed a doc/example somewhere, could you pls point?
Please read: https://github.com/johnagan/clean-webpack-plugin/issues/106
My guess is you can replace your config with:
new CleanWebpackPlugin({
dry: true, // remove this once you verify it removes the correct files
verbose: true,
});
@pgnd is your issue resolved?
@chrisblossom
Minor add'l tweak did the trick here
with explicit config,
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
exports.clean = path => ({
plugins: [
new CleanWebpackPlugin({
dry: false,
verbose: true,
cleanStaleWebpackAssets: true,
protectWebpackAssets: false,
cleanOnceBeforeBuildPatterns: ['**/*'],
})
],
});
exec of
parts.clean([
PATHS.build,
PATHS.cache,
etc
etc
]),
works a charm!
o/
That's great. FYI, your path
param doesn't do anything.
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
exports.clean = () => ({
plugins: [
new CleanWebpackPlugin({
dry: false,
verbose: true,
cleanStaleWebpackAssets: true, // this can be removed as it is the default
protectWebpackAssets: false, // I do not see you removing non-webpack assets, not sure why this is set to false.
cleanOnceBeforeBuildPatterns: ['**/*'], // this can be removed as it is the default
})
],
});
parts.clean();
it only worked me when I tried this stackoverflow answer that has the most upvotes and $npm start
(or whatever start means in your package.json)
I'm currently seeing the same error as closed/locked
https://github.com/johnagan/clean-webpack-plugin/issues/143
here, with
and
on exec, still
is this a new-, or re-, occurrence? or, something obvious I'd missed ?