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

CSS not being compressed #422

Closed
adamhl8 opened this issue Oct 22, 2024 · 3 comments
Closed

CSS not being compressed #422

adamhl8 opened this issue Oct 22, 2024 · 3 comments
Assignees

Comments

@adamhl8
Copy link

adamhl8 commented Oct 22, 2024

I'm not able to compress the CSS generated by astro.

Error: Cannot compress file //dist/_astro/_slug_.CPIc14WV.css
Error: Cannot compress file //dist/_astro/_slug_.Dvd5riTk.css

In #376 it's mentioned that if a file doesn't need compression an error is thrown, but I don't think that's what's happening in my case.

I manually installed lightningcss and ran it on one of the files and it went from 52KB to 48KB, so it can definitely be compressed.

I thought it might be something with csso specifically, so I tried setting the parser to just lightningcss, but I still get the same error.

playformCompress({ Parser: { CSS: "lightningcss" } }),

If you'd like to reproduce, it's on the branch compress on my repo: https://github.com/adamhl8/adamhl.dev

@geepot
Copy link

geepot commented Oct 22, 2024

Running into this same issue in my environment

@NikolaRHristov
Copy link
Member

We found the error.

We're setting unusedSymbols to false in

unusedSymbols: false,
and it's producing the error:

Error: invalid type: boolean `false`, expected a sequence

As a hotfix I would recommend setting unusedSymbols to []:

import type { defineConfig } from "astro/config";

export default (await import("astro/config")).defineConfig({
	integrations: [
		(await import("@playform/compress")).default({
			CSS: {
				lightningcss: {
					unusedSymbols: [],
				},
			},
		}),
	],
}) as typeof defineConfig;

@NikolaRHristov
Copy link
Member

Fixed in the latest @playform/[email protected] and [email protected]

@adamhl8 adamhl8 closed this as completed Oct 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants