purgecss
purgecss copied to clipboard
[Bug]: purgecss-webpack-plugin only takes the path not the entry
Describe the bug
Hello,
I found a bug on the plugin. I wanted to use the only option to use the purge only on my 'style' entry. So I do a stuff like that :
{
name: 'style',
entry: {
style: [ /* .... */ ].filter(Boolean),
vitamin: [ /* .... */ ].filter(Boolean),
},
resolve: { plugins: [teamResolver(team)] },
module: {
rules: [ /* ... */ ],
},
plugins: [
// others plugins
new MiniCssExtractPlugin({
filename: 'client/style/[name].[contenthash].css',
}),
new PurgeCSSWriterPlugin({
paths: () => globAll.sync(['./src/**/*'], { nodir: true }),
only: ['style'],
// other options
}),
],
}
So, when I build my project, all the 2 entries are purged ! But only
should include only script
.
I have check the source code, and I see this :
if (this.options.only) {
return this.options.only.some((only) => name.includes(only)); // Name is the target path of the file !
}
So, in my case, I have style
on all the 2 paths, the plugin will be executed on the 2 files and not the filename (endpoint like the documentation say)
To Reproduce
Create a webpack configuration with 2 entries style
and style_hello_world
, set the option only to style
.
Expected Behavior
The option only
should check the entry name and not the full path of the file.
Environment
macos purgecss-webpack-plugin: ^4.1.3
Add any other context about the problem here
context
Code of Conduct
- [X] I agree to follow this project's Code of Conduct