-
Notifications
You must be signed in to change notification settings - Fork 28
feat(styles-loader): disable purgecss by default #614
Conversation
@code-forger @Matthew-Mallimo so we are planning on a major version bump for this? |
@10xLaCroixDrinker I was hoping to consider this a It would be very unfortunate to have to version bump immediately after a major. |
e09e75c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm interested in purgecss starts by assuming that 0 selectors are used, and then adds any selectors it finds being used
, where did you find that? documentation? code?
I think that's confusing the the work
|
I'm not stoked about it, but I'm okay with this. However, the commit type MUST be changed to fix. |
I had heard about this and sort of just took it at face value 😅 agreed that my original statement isn't true, thanks for flagging and clarifying 😄 A better way to describe the thinking behind that statement is that we must provide a complete list of ASTs (or paths to files) to purgecss that could reference a css class. If an AST is not provided to purgecss that references a class, then any of the classes used by that AST will be considered unused and purged (unless referenced in some other file). |
Description
Makes
purgecss
disabled by default, requiring users to explicitly opt-in topurgecss
by settingbundler.purgecss.enabled
totrue
, orbundler.purgecss.disabled
tofalse
. Additionally, removes the check forNODE_ENV === 'production'
when executing purgecss to ensure a consistent experience between different environments.Motivation
purgecss
has been a common point of confusion for users of one-app. During development, users typically bundle using the dev bundler, which does not purge any css. After development, users will switch to the production bundler, at which point css is purged as an optimization technique.This works great, but only if perfect defaults are supplied to the purgecss plugin for which content to analyze for unused selectors.
purgecss
starts by assuming that 0 selectors are used, and then adds any selectors it finds being used, which typically results in a few cases where selectors are removed that are actually being used. Because modules can be so diverse, it's not possible to provide perfect defaults without incurring massive performance penalties on bundle times.As a result, users will often notice (later than they might like) that css gets purged from their module that they don't expect to be purged. Because this is an optimization technique, it is reasonable to let users choose to opt-in to purgecss, with the understanding that they must customize the config to ensure that only unused css classes get purged from their bundle.
Test Conditions
Modified existing unit tests to check that css is purged only when explicitly enabled. Additionally, added new tests to verify that purgecss executes when
NODE_ENV
is set todevelopment
.Types of changes
Checklist