#Possible to disable CSS minification?
19 messages · Page 1 of 1 (latest)
@void spade Just searched a bit and found a PR of yours:
https://github.com/withastro/astro/commit/d7688f05c216a706105854474ba1caa737594871#diff-6b416e91b57562a024efa9947ff14a340bdd0edbca71f3c3d08531d9dfa29ea3R175
which has been moved to:
https://github.com/withastro/astro/blob/64aa903f04cd3fe1f531f577bf8900bf098006dc/packages/astro/src/core/build/vite-plugin-css.ts#L233
Seems like the minification is hard-coded. Do you have any recommendations for preventing that from happening?
Do you think this would be a viable change?
+ const minify = settings.config.vite.build?.minify ?? true;
const { code: minifiedCSS } = await esbuild.transform(output.source, {
loader: 'css',
- minify: true,
+ minify,
...(cssTarget ? { target: cssTarget } : {}),
});
Just tried it out, that resolved the issue I was having. Seems like some parsers are having trouble with the minified output (Prettier, Vivliostyle, etc).
Does Vite have a way to disable minification for CSS and not JS?
if so we should support that option
otherwise i think you have to turn off minify completely
No, there is an open issue for that:
That's a workable solution for the time being.
Vite does currently use build.minify for CSS:
https://github.com/vitejs/vite/blob/8f315a20a7c3a33c72e7993860b6b69f5d6f0e05/packages/vite/src/node/plugins/css.ts#L425-L427
I think it would make for a more intuitive DX if Astro implemented (vite.build?.minify ?? true) instead of hardcoding true, at both of these points:
• core/build/static-build.js/clientBuild
• core/build/vite-plugin-css.js/rollupPluginAstroBuildCSS
oh yeah, for sure, we should be using the config option
Cool, just submitted a PR:
https://github.com/withastro/astro/pull/4803
Oh, we want to not minify the server JS
So this change has to be a little more complex, unfortunately
I'll explain in the PR
Haven't done much OSS. So my initial thought was oops - dumb mistake
, since it's an isolated branch I'll just amend + force push it to keep a concise commit history instead of
- [chore] did the thing
- [fix] fixed the chore to actually do the thing
But then afterwards I noticed that you had made a change request & left a comment, but I can't actually see anything there so it seems like amendments interfere w/ the review workflow.
Idk, on my personal repos I prefer to amend & keep the commit history concise. But I'm guessing in this context it's likely preferable to not do things that affect the review workflow?