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

Why is css reduced even with everything ignored? #294

Closed
dhymik opened this issue Feb 27, 2020 · 4 comments
Closed

Why is css reduced even with everything ignored? #294

dhymik opened this issue Feb 27, 2020 · 4 comments

Comments

@dhymik
Copy link

dhymik commented Feb 27, 2020

I have one single scss file being processed by Gulp 4, this is tailwind.scss.

Without purgecss, the resulting css is 1,5 MB in size.
With purgecss in the chain, it is 24 kByte.
With purgecss and everything in tailwind.scss ignored, css size is 600 kByte.

My tailwind.scss file looks like this:

@charset "UTF-8";

/* purgecss start ignore */
@import "_baseStyles.scss";
@import "_components.scss";
@import "_utilities.scss";
@import "_design.scss";
/* purgecss end ignore */

Why is css file size reduced from 1,5 MBytes to 600 kBytes with everything ignored?

@dhymik dhymik changed the title Why is css purged even when everything is ignored? Why is css reduced even with everything ignored? Feb 27, 2020
@joshua-martin
Copy link

@dhymik I cant see this behaviour, if I run purgecss with everything ignored, my file the same size. Are you running anything that is stripping comments prior to your purgecss step?

@janko
Copy link

janko commented Mar 15, 2020

I had the same problem. What I noticed is that my SASS compiler seemed to remove the CSS comments, so when it came for PurgeCSS to do its thing, it didn't find any ignore comments in the compiled CSS. I found that strange, because according to SASS language specification, comments should be retained. Maybe sass-loader is set to remove comments in production mode 🤷‍♂

@I-Want-ToBelieve
Copy link

If you use sass-loader, exactly, sass-loader-minify ... then the comments you wrote to purgecss have been deleted by sass-loader! !!

webpack-contrib/sass-loader#763

@dhymik
Copy link
Author

dhymik commented Apr 22, 2020

The reported issue was caused by the Sass compiler. I solved the issue by modifying the css ignore comments to

/*! purgecss start ignore */
/*! purgecss end ignore */

Note the exclamation mark behind the opening comment tag. This instructs SASS to leave the comments in even in compress mode. See SASS docs here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants