Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Getting error TypeError: pattern is too long and application is crashing when using purgeCss. #1218

Open
1 task done
vikaskrsharma opened this issue Feb 18, 2024 · 0 comments
Labels

Comments

@vikaskrsharma
Copy link

vikaskrsharma commented Feb 18, 2024

Describe the bug

I am using server side rendering with react and using webpack & ChunkExtractor to build cssString and html on server side. To purge unused css when using the purgeCss with html as string and css as string, i am getting 'TypeError: pattern is too long' error and my application crashed. Here is how i am using purgeCss:

import { PurgeCSS } from 'purgecss';
const reactHtml = renderToString(jsx);
const purgeCSSResults = await new PurgeCSS().purge({
content: [reactHtml],
css: [cssString],
});
const purgedCssString = purgeCSSResults[0].css;

And i am supplying this purgedCssString to a template to extract the header along with all the styles in tag and footer.

To Reproduce

Supply a large html as string and css as string to purge();

Expected Behavior

It should give a cssString with all unused css removed.

Environment

node

Add any other context about the problem here

context

Code of Conduct

  • I agree to follow this project's Code of Conduct
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant