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

ESM PostCSS configs option #209

Open
nosovk opened this issue May 27, 2022 · 11 comments
Open

ESM PostCSS configs option #209

nosovk opened this issue May 27, 2022 · 11 comments
Assignees
Labels
adder:postcss Relates to the PostCSS adder enhancement New feature or request

Comments

@nosovk
Copy link

nosovk commented May 27, 2022

postcss-load-config now supports esm configs.
postcss/postcss-load-config#234

After accepting of sveltejs/svelte-preprocess#520 we can update generated config to .js instead of .cjs

@babichjacob
Copy link
Member

This is great news! Thank you for the heads up — I wouldn't have heard about this without it!

@babichjacob babichjacob added adder:postcss Relates to the PostCSS adder enhancement New feature or request upstream Can only be solved by an upstream project's changes labels May 28, 2022
@oneezy
Copy link

oneezy commented Jun 10, 2022

Bumping this up.

@babichjacob babichjacob removed the upstream Can only be solved by an upstream project's changes label Jun 10, 2022
@babichjacob babichjacob self-assigned this Jun 10, 2022
@oneezy
Copy link

oneezy commented Jun 13, 2022

correct me if i'm wrong, but this will allow using ESM for Tailwind config now too? so both tailwind.config.js and postcss.config.js will be JavaScript files and not CommonJS ?

@babichjacob babichjacob removed their assignment Jun 15, 2022
@babichjacob babichjacob added the upstream Can only be solved by an upstream project's changes label Jun 15, 2022
@babichjacob
Copy link
Member

It turns out that Vite itself has to be updated to support ESM PostCSS configs (because it doesn't use postcss-load-config) before we can use them in our projects. 😞

@babichjacob
Copy link
Member

correct me if i'm wrong, but this will allow using ESM for Tailwind config now too? so both tailwind.config.js and postcss.config.js will be JavaScript files and not CommonJS ?

We have to wait for Tailwind themselves to update both their library (PostCSS plugin) and IntelliSense extension to support ESM configs; we're not getting it for free with PostCSS supporting ESM configs, unfortunately.

@oneezy
Copy link

oneezy commented Jun 17, 2022

We have to wait for Tailwind themselves to update both their library (PostCSS plugin) and IntelliSense extension to support ESM configs; we're not getting it for free with PostCSS supporting ESM configs, unfortunately.

Ah man that sucks! hopefully they get out some updates soon. I'm hoping there's some open issues on their ends.

@babichjacob
Copy link
Member

I forgot we can import PostCSS config and give it to Vite without using their loader, so this is a note to self to try that.

@babichjacob babichjacob changed the title Post-CSS now supports ESM configs Post-CSS might support ESM configs Jun 28, 2022
@babichjacob
Copy link
Member

The answer is yes! Since this is a little weird, I'll implement it as an option.

@babichjacob babichjacob changed the title Post-CSS might support ESM configs ESM PostCSS configs option Jun 30, 2022
@babichjacob babichjacob removed the upstream Can only be solved by an upstream project's changes label Jun 30, 2022
@babichjacob babichjacob self-assigned this Jun 30, 2022
@divStar
Copy link

divStar commented Aug 21, 2022

I just wanted to chime in. From what little I understand, it's not just that a svelte-add issue, is it?

When I have a tailwind.config.js (note the extension: it's js not cjs) and in the package.json type is set to module, apparently vite doesn't know how to handle the tailwind configuration. I do need the tailwind configuration though, to build a method, that discovers the current breakpoint being used in order to either deliver e.g. long names (of e.g. months) or short ones.

Or is there a way to do it? Is this even the correct place to ask or should I go to Stackoverflow and pray someone with the actual knowledge responds?

@babichjacob
Copy link
Member

You're right, Tailwind itself must be updated to support ESM configs. We are however able to write the PostCSS config in ESM, wherein the Tailwind plugin will still use the tailwind.config.cjs file

@oekazuma
Copy link

Now that Tailwind CSS supports ESM, we can push this forward!

https://tailwindcss.com/blog/tailwindcss-v3-3#esm-and-typescript-support

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
adder:postcss Relates to the PostCSS adder enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants