#Possible to disable CSS minification?

19 messages · Page 1 of 1 (latest)

iron walrus
#

I have a build that produces CSS which is not parsed properly by @vivliostyle/cli. It works fine after un-minifying it.

#

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 } : {}),
});
iron walrus
#

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).

void spade
#

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

iron walrus
iron walrus
# void spade otherwise i think you have to turn off minify completely

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

void spade
#

oh yeah, for sure, we should be using the config option

iron walrus
void spade
#

So this change has to be a little more complex, unfortunately

#

I'll explain in the PR

iron walrus
# void spade I'll explain in the PR

Haven't done much OSS. So my initial thought was oops - dumb mistake dv_pikaFacePalmOwO, 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?

void spade
#

When we merge all of the commits get squashed into 1

#

So you don't have to worry about rebasing in your branch