-
Notifications
You must be signed in to change notification settings - Fork 149
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
Strange behavior with postcss and custom languages #309
Comments
Hey @non25 👋 this happens because we purposefully run postcss after a possible style preprocessor, so it's possible to have postcss being executed after a scss style was preprocessed. It's the same for the babel preprocessor. It always runs after a script tag was preprocessed. This assumption may not be 100% right, but changing this behavior would be a big breaking change |
Hi @kaisermann 🙂 Thanks for a fast response. What do you think about having an option which controls such behavior ? And more important, what about double run for custom languages ? Is that intentional too ? 🤔 |
@non25 Can you provide a minimal repro with that happening? And, in theory, the mechanism to disable such postcss behavior would be |
@kaisermann Sure, take a look. /~https://github.com/non25/svelte-template-webpack/commits/svelte-preprocess-repro I suppose it should launch Now I understand why I'm kinda spoiled with webpack's pipelines, which allows me to do crazy stuff like this: Not like it is sane, but I can. 😀 The only configuration I can think of which can't be done properly is the follwing one:
Ideally, I would want one plugin list for Maybe we could turn off successive { code, map, disablePostcss: true } or { ..., skipPostcss: true } That way we could control |
Oh, interesting! There's indeed an issue here. We're getting double |
Cool. 🙂 |
IMO, having something like |
Is there a good-looking way to wrap default Edit: /~https://github.com/sveltejs/svelte-preprocess/blob/main/docs/preprocessing.md#overriding-preprocessors uh oh 🙂 That's what I end up with: scss(data) {
return scss().style(data).then(({ code: content, map }) => {
postcss().style({ ...data, content, map })
});
}
// or
scss: async (data) => {
const { code: content, map } = await scss().style(data);
return await postcss().style({ ...data, content, map });
} Can't think of something less ugly than this. 🙂 |
@non25 That option exists as a way to override the lib's native transformers, not extend them. I wouldn't say your way is ugly considering what you want to do. |
I've been messing around with
svelte-preprocess
, trying to squeeze more performance fortailwindcss
and got some interesting results instead...For example I can make custom langs, to make purpose-fit performant configs for certain tasks.
And every time component with
lang="custom"
is being built, I get two console logs, indicating that postcss has run twice instead of once. 🤔Also I can configure postcss for
lang="postcss"
how I see fit just forsvelte-preprocess
, and make some default configuration for regular style tags while I'm at it:And I will get both of them run for regular style tags.
So if I use
postcss: true
orpostcss() {...}
function - it will launch it for regular style tags along with what I have defined as default.The only way to prevent this from happening is to avoid using truthy
postcss
key in config.I don't think
svelte-preprocess
should work like this. It is unintuitive at best. 🤔The text was updated successfully, but these errors were encountered: