You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This would not be a sensible default to leave enabled. This would break sites that rely on predictable selectors to function properly. Leaving the flag off on builds destined for integration testing would make them easier to author. A flag would seem most suitable.
Is your proposal related to a problem?
Describe the solution you'd like
A
MINIFY_CSS
flag that enables style minification. A cousin to theGENERATE_SOURCEMAP
option. Only operates for production builds.If enabled, appropriate options could be passed to css-loader here (and postcss-loader):
https://github.com/facebook/create-react-app/blob/main/packages/react-scripts/config/webpack.config.js#L131
Or to css-minimizer-webpack-plugin here:
https://github.com/facebook/create-react-app/blob/main/packages/react-scripts/config/webpack.config.js#L300
The webpack.config.js has a
shouldUseSourceMap
that derives fromGENERATE_SOURCEMAP
.An implementation suggestion from an earlier request is here: #8984 (comment)
An example of someone ejecting to achieve this: https://medium.com/swlh/minifying-tailwind-css-with-create-react-app-b8615a82b33b
This would not be a sensible default to leave enabled. This would break sites that rely on predictable selectors to function properly. Leaving the flag off on builds destined for integration testing would make them easier to author. A flag would seem most suitable.
Describe alternatives you've considered
Did not find a relevant flag in existing set: https://create-react-app.dev/docs/advanced-configuration
Aside from ejecting, running cssnano on resulting build output. Haven't tried since it would introduce fragility.
Additional context
Earlier requests for this feature marked stale here:
#8984
#6349
Larger scope: It may be worth considering a flag to remove unused styles via something like https://purgecss.com/
The text was updated successfully, but these errors were encountered: