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

Disable CSS minification (independently of JS) #5619

Closed
cbergen opened this issue Nov 11, 2021 · 7 comments · Fixed by #12207
Closed

Disable CSS minification (independently of JS) #5619

cbergen opened this issue Nov 11, 2021 · 7 comments · Fixed by #12207
Labels
enhancement New feature or request feat: css p3-downstream-blocker Blocking the downstream ecosystem to work properly (priority)

Comments

@cbergen
Copy link

cbergen commented Nov 11, 2021

I prefer to use cssnano and would like to be able to turn off just CSS minification.

More specifically, I am using Vite which is built-in to SvelteKit. The current version of esbuild and terser which is packaged with Vite both incorrectly merge rules which shouldn't be merged. Cssnano has it figured out and can manage this case.

Suggested solution

Ideally a new Vite option would expose this ability.

@Niputi
Copy link
Contributor

Niputi commented Nov 11, 2021

@cbergen
Copy link
Author

cbergen commented Nov 11, 2021

Thanks @Niputi but that also turns off javascript minification, alas.

If using Terser, there are terser minification options but I don't see anything that relates to my specific issue (disabling the merging of css rules). https://vitejs.dev/config/#build-terseroptions

@scsskid
Copy link

scsskid commented May 13, 2022

build.minify: false doesnt affect style assets at all for me

@FatehAK
Copy link

FatehAK commented Dec 14, 2022

Is this feature available? I would like to use cssnano as well since it merges style rules better saving bytes.

@misaon

This comment was marked as spam.

@bluwy bluwy moved this from Discussing to P2 - 4 in Team Board Feb 18, 2023
@bluwy bluwy added the p2-to-be-discussed Enhancement under consideration (priority) label Feb 18, 2023
@Rich-Harris
Copy link
Contributor

Conversely, we'd like to be able to ensure that CSS emitted from the server build (when using ssrEmitAssets) is minified, or at least that the same minification is used in both cases. The reason is that if you're copying over server-emitted assets (which is necessary to allow server code to use the paths of assets that are not referenced by client code, e.g. to generate an <img> tag in server-rendered HTML), you'll end up with two copies of each .css file — one minified, one not, with different hashes in each case.

This is problematic because the list of assets is used in things like service workers, which will then cache files that will never be referenced by the application.

@bluwy bluwy moved this from P2 - 4 to Approved in Team Board Feb 24, 2023
@bluwy
Copy link
Member

bluwy commented Feb 24, 2023

In the recent meeting, we decided to expose a new build.cssMinify: boolean option to support this usecase. It should default to the (resolved) build.minify value, unless explicitly specified a different value.

@bluwy bluwy added enhancement New feature or request p3-downstream-blocker Blocking the downstream ecosystem to work properly (priority) feat: css and removed feat: css p2-to-be-discussed Enhancement under consideration (priority) labels Feb 24, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Mar 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request feat: css p3-downstream-blocker Blocking the downstream ecosystem to work properly (priority)
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

7 participants