I cannot get melte to use postcss in <style> blocks load recent PostCSS plugin versions.
UPDATE: I finally figured out that it's something to do with using a plugin that's been updated for PostCSS 8. Downgrading the plugin, e.g., postcss-nested@4, makes everything work fine. I can't figure out how to edit melte-complier to make it compatible with the new plugin API, but for now at least I can just stick with older plugin versions.
Minimal reproduction
See also my repo with the results of these steps.
meteor create --svelte
meteor npm install --save-dev postcss postcss-load-config postcss-nested
- Create
postcss.config.js to load postcss-nested plugin (like this)
- Set
svelte:compiler's css option to false in package.json (like this)
- Add a
<style lang="postcss"> block with a nested rule to App.svelte (like this)
Expected: postcss-nested plugin will transform the nested rule to proper CSS.
Actual: Build fails with imports/ui/App.svelte: Colon is expected (the exact error depends on the invalid CSS I've written)
Note: PostCSS works with .css files: If I put a nested rule in main.css it gets transformed properly. It only fails to transform CSS in .svelte files
Other things I've tried
- Putting PostCSS config in
package.json
- Swapping out
standard-minifier-css for juliancwirko:postcss
- Setting
css: true in svelte:compiler options
meteor reset
- Doing this in my actual web app project
- Setting the
postcss option of svelte:compiler in package.json (see second post below)
Any ideas? I'm going crazy trying to get this to work. I love being able to use Svelte in Meteor, but it's been a drag to either write vanilla CSS or have to keep my styles in separate files. As I said above, this is working with older plugin versions now. Wish I could figure out how to update the package to be compatible with the most recent API, but I can't.
Thank you for looking! 🙏
I cannot get melte to
use postcss inload recent PostCSS plugin versions.<style>blocksUPDATE: I finally figured out that it's something to do with using a plugin that's been updated for PostCSS 8. Downgrading the plugin, e.g.,
postcss-nested@4, makes everything work fine. I can't figure out how to editmelte-complierto make it compatible with the new plugin API, but for now at least I can just stick with older plugin versions.Minimal reproduction
See also my repo with the results of these steps.
meteor create --sveltemeteor npm install --save-dev postcss postcss-load-config postcss-nestedpostcss.config.jsto loadpostcss-nestedplugin (like this)svelte:compiler'scssoption tofalseinpackage.json(like this)<style lang="postcss">block with a nested rule toApp.svelte(like this)Expected:
postcss-nestedplugin will transform the nested rule to proper CSS.Actual: Build fails with
imports/ui/App.svelte: Colon is expected(the exact error depends on the invalid CSS I've written)Note: PostCSS works with
.cssfiles: If I put a nested rule inmain.cssit gets transformed properly. It only fails to transform CSS in.sveltefilesOther things I've tried
package.jsonstandard-minifier-cssforjuliancwirko:postcsscss: trueinsvelte:compileroptionsmeteor resetpostcssoption ofsvelte:compilerinpackage.json(see second post below)Any ideas? I'm going crazy trying to get this to work. I love being able to use Svelte in Meteor, but it's been a drag to either write vanilla CSS or have to keep my styles in separate files.As I said above, this is working with older plugin versions now. Wish I could figure out how to update the package to be compatible with the most recent API, but I can't.Thank you for looking! 🙏