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

A css comment vanish if I comment out this line #2869

Closed
frederikhors opened this issue Nov 23, 2021 · 4 comments
Closed

A css comment vanish if I comment out this line #2869

frederikhors opened this issue Nov 23, 2021 · 4 comments

Comments

@frederikhors
Copy link
Contributor

frederikhors commented Nov 23, 2021

Describe the bug

I created a new SvelteKit app (with command from https://kit.svelte.dev/docs#introduction-getting-started):

npm init --yes svelte@next my-app

Here the repo: https://github.com/frederikhors/iss-svelte-kit-tailwind-comments

I added Tailwind in this commit: https://github.com/frederikhors/iss-svelte-kit-tailwind-comments/commit/84906710c497d57c8394430a482049605c2c390f.

If you run the project with npm run dev (after npm install of course) it works (Tailwind works, there is a bg-red-500 in __layout.svelte).

What doesn't work is this crazy thing:

If you build with

rm -rf ./node_modules/.vite/ && rm -rf build && npm run build

and open the css in build/_app/assets/pages/__layout.svelte-[NUMBERS].css you can search for "I_need_this_comment" (which is a comment in src/app.css) and you can find it in the final css bundle.

Now if you comment out the first line in src/app.css enabling @tailwind base; and build again with the same command the comment is lost!!!

This drove me crazy!

Can you please help me understand what is going on?

Thanks!

Severity

serious, but I can work around it

@rmunn
Copy link
Contributor

rmunn commented Nov 23, 2021

Looks like postcss may be what's removing the comments. I'd suggest opening an issue there, because I doubt this is a Svelte-Kit bug per se.

BTW, I experimented with your repro and found that if you move the @tailwind base line to below the comment, the comment isn't removed. I don't have time to pursue this further, but hopefully that will help you with narrowing this down.

I'll leave this issue open for now, just in case there really is a Svelte-Kit bug. But at the moment, I'm thinking it's something to do with postcss and not Svelte-Kit.

@frederikhors
Copy link
Contributor Author

@rmunn thanks. I tried with the comment on the first line, it isn't removed, but I need other comments after the @tailwind base line too. 😢

@frederikhors
Copy link
Contributor Author

@rmunn @ai answered postcss/postcss#1678 (comment). 😭

I opened this too: tailwindlabs/tailwindcss#6182

@dominikg
Copy link
Member

tailwind author tracked this down to being an esbuild css minification issue: evanw/esbuild#1796

please follow up there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants