Style tag `lang` attribute triggers warning from Svelte Beta
See original GitHub issueDescribe the bug
When specifying a lang
attribute in component’s <style>
tag, Svelte Beta for VS Code gives the following warning:
The file cannot be parsed because script or style require a preprocessor that doesn't seem to be setup. Did you setup a `svelte.config.js`? See https://github.com/sveltejs/language-tools/tree/master/packages/svelte-vscode#using-with-preprocessors for more info.
This only happens when specifying the lang
attribute on the component <style>
. When the lang attribute is removed from the <style>
tag, the warning goes away, regardless of if there is a lang
attribute on the component <script>
tag.
To Reproduce Steps to reproduce the behavior:
- Create a new Svelte + Webpack project by using:
degit svelte/template-webpack
- Install TypeScript, Node Sass, and Svelte Preprocess:
npm i -D typescript node-sass svelte-preprocess
- Create a svelte.config.js:
const sveltePreprocess = require('svelte-preprocess')
module.exports = {
preprocess: sveltePreprocess()
}
- Restart Svelte Beta in VS Code
- Add
lang="scss"
to<style>
tag insrc/App.svelte
- Save file. Svelte Beta warning should appear on
<script>
tag
Expected behavior Expected Svelte Beta to not return any warnings or errors.
Screenshots
System:
- OS: Windows 10
- IDE: VSCode 1.45.0
- Plugin/Package: “Svelte Beta”
Additional context Frequently recommended/obvious fixes that did not work:
- Double, triple, and quadruple checked that I had a
svelte.config.js
file at the root of my project. - Tried setting runtime to path to Node.js:
C:\Program Files\nodejs\node.exe
- Tried the following variants of svelte.config.js:
const sveltePreprocess = require('svelte-preprocess')
module.exports = {
preprocess: [sveltePreprocess()]
}
const sveltePreprocess = require('svelte-preprocess')
module.exports = {
preprocess: sveltePreprocess({
sass: true
})
}
const sveltePreprocess = require('svelte-preprocess')
module.exports = {
preprocess: sveltePreprocess({
sass: true,
typescript: true
})
}
- Webpack configuration uses preprocess options exported by
svelte.config.js
and compiles Svelte code with no errors or warnings.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:6
- Comments:30 (12 by maintainers)
Top Results From Across the Web
Docs • Svelte
To change component state and trigger a re-render, just assign to a locally declared variable. Update expressions ( count += 1 ) and...
Read more >A Step-by-Step Guide to Svelte Localization | Phrase
Still quite new but powerful, the Svelte framework has found a solid niche for itself. Here's how to implement Svelte localization!
Read more >Elder.js: A Svelte Framework and Static Site Generator
Elder.js is an opinionated Svelte framework and static site generator used for building blazing fast, user friendly websites.
Read more >1 Meet the players - Svelte and Sapper in Action
In Angular, styles specified in the styles property of a component are also ... using the VS Code extension "Svelte Beta" which uses...
Read more >Meet Skeleton: Svelte + Tailwind For Reactive UIs
Design Systems With Tailwind #. First introduced in 2019, Tailwind provides a unique utility-based approach to CSS and styling. When designing ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I tried this and the problem I run into can be fixed by setting
svelte.language-server.runtime
like @dummdidumm suggested. @JoeBobMiles you can try to requirenode-sass
in a js file and run the file with node to see if there are any errors.It is documented and the warning in the IDE does also hint at this.