-
-
Notifications
You must be signed in to change notification settings - Fork 207
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
svelte(css-syntax-error) when using postcss-preset-env custom media #517
Comments
For your specific case: Svelte files are transpiled per-file, so it does not know anything about that |
Thank you very much for the response. I really appreciate your effort on this I decided to post about this only because previously for a couple of weeks I'v been using those custom media queries and there was no error but after some update (I suppose) now there is one. Also this could become part of css spec in the future, who knows. I hope it will at least be fixed then. Thanks |
You need to somehow make the custom-media from media-queries.css also available from the preprocess of |
If I try this exact code that you posted it generates a new error
"postcssPresetEnv is not a function". Even if I remove .default I still see
an error. Still thank you very much for taking a look at this.
…On Fri, 4 Sep 2020 at 09:37, Lyu, Wei-Da ***@***.***> wrote:
the problem you're having is the setup of preprocessor in svelte.config.js.
You have three plugins loaded in your rollup config. but only enable auto
preprocessing on svelte.config.js so the IDE's compile process doesn't get
the preprocessed style thus throwing the error.
I tried this in the svelte.config.js and the error goes away.
const sveltePreprocess = require('svelte-preprocess')const postcssImport = require('postcss-import')const postcssPresetEnv = require('postcss-preset-env').defaultconst postcssNested = require('postcss-nested')
const postcssPlugins = [
postcssImport(),
postcssPresetEnv({ stage: 0 }),
postcssNested(),]
module.exports = {
preprocess: sveltePreprocess({
sourceMap: true,
postcss: {
plugins: postcssPlugins,
},
})}
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#517 (comment)>,
or unsubscribe
</~https://github.com/notifications/unsubscribe-auth/AC6ONEK5L3PDUXKDVGIWFMLSECDKVANCNFSM4QTPHU5Q>
.
|
Sorry for that I found it doesn't work XD |
I found a workaround (hope I didn't jump to the conclusion too fast again lol) // svelte.config.js
const sveltePreprocess = require('svelte-preprocess')
const fs = require('fs')
const mediaQueries = fs
.readFileSync('./src/assets/css/media-queries.css')
.toString()
module.exports = {
preprocess: sveltePreprocess({
postcss: {
prependData: mediaQueries,
},
}),
} About the build, I guess it's because you declare the custom-media in your app.svelte. Once I remove it and restart the dev server the same error you encounter in the IDE appears. |
@jasonlyu123 You are just amazing! You solved both issues in one go (having media queries in two places wasn't great as well). I really appreciate this, now I can work with pleasure. Thanks again and good luck in everything! |
To Reproduce
You can use my repo to reproduce it /~https://github.com/shamsartem/dbudget
Check default.svelte for errors.
Alternatively:
Expected behavior
There shouldn't be an error in this case
System (please complete the following information):
The text was updated successfully, but these errors were encountered: