-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
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
fix: support ?raw for css #2148
Conversation
Can you add test for it? |
OK, done. |
Hmm, you don't need If |
But if you don't add |
That's why I'm considering a change: // gets the string, but does not insert
import css from './foo.css'
// insert on import, does not generate `export default ...`
import './foo.css' But semantically es import syntax should not affect behavior so I'm still debating. |
I agree that it is better if they are semantically equivalent. Maybe adding a new special query for this?
|
Yeah I think another query is somewhat required for now. How about Also note in the future there might be native behavior for CSS imports: https://github.com/WICG/webcomponents/blob/gh-pages/proposals/css-modules-v1-explainer.md (it will likely require a breaking change or a global option like |
At least for me, |
I think it's fine if we document it:
|
This seems fine to me. The proposed behavior of each is intuitive. It's exactly what we do in |
{
name: 'raw-css',
transform(code, id) {
if (id.endsWith('.css?raw') && code.startsWith('export default ')) {
return JSON.parse(code.slice('export default '.length))
}
},
} |
Please consider implementing this in a way that is likely to be compatible with the upcoming CSS module scripts. |
Any news on this issue? The pull request is already 5 months old. |
This PR has been superseded by e1de8a8 There will be an |
Perhaps it would be worth adding it to the docs? |
Has anybody been able to get this working when bundling with rollup (with typescript)? But I digress, using the inline I haven't been able to find a way to get rollup to work with it. During development with Vite it works no problem, but once you try to bundle it is when it won't cooperate. |
No description provided.