[Bug]: Webpack: TypeError: PurgeCSSPlugin is not a constructor
See original GitHub issueDescribe the bug
After upgrading to 5.0.0, my webpack build failed with TypeError: PurgeCSSPlugin is not a constructor
.
To Reproduce
Use webpack plugin with current instructions:
const PurgeCSSPlugin = require('purgecss-webpack-plugin')
then somewhere new PurgeCSSPlugin(...)
Expected Behavior
Webpack build succeeds.
Environment
v. 5.0.0
Add any other context about the problem here
I fixed my problem by simply changing
const PurgeCSSPlugin = require('purgecss-webpack-plugin');
to
const { PurgeCSSPlugin } = require('purgecss-webpack-plugin');
I don’t know if this change was intended with the 5.0.0 update. If yes, it would be a quick fix in the webpack plugin instructions 😃
Code of Conduct
- I agree to follow this project’s Code of Conduct
Issue Analytics
- State:
- Created a year ago
- Reactions:17
- Comments:12
Top Results From Across the Web
Webpack 5 - PurgeCss - Not a Constructor Error
So apparently this is a webpack-purgecss-plugin 5.0 issue since webpack 5.0 So I downgraded the plugin to 4.1.3 and it works again.
Read more >'Purgecss is not a constructor' when following the JS API ...
Hi, I'm trying to follow the ES5 JS API examples but it looks like something is going wrong with the export as I'm...
Read more >PurgeCSSPlugin.(constructor)
PurgeCSSPlugin.(constructor). Constructs a new instance of the PurgeCSSPlugin class. Signature: constructor(options: UserDefinedOptions); ...
Read more >purgecss-webpack-plugin - npm
PurgeCSS plugin for webpack - Remove unused css. Latest version: 5.0.0, last published: 3 months ago. Start using purgecss-webpack-plugin in ...
Read more >Removing unused CSS with Purgecss/UnCSS - sage
// resources/assets/build/webpack.config.optimize.js // ... const glob = require('glob-all'); const PurgecssPlugin = require('purgecss-webpack-plugin'); module ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
it looks like it should be
Check my comment just before @Dave3of5 😃