question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Style tag `lang` attribute triggers warning from Svelte Beta

See original GitHub issue

Describe 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:

  1. Create a new Svelte + Webpack project by using: degit svelte/template-webpack
  2. Install TypeScript, Node Sass, and Svelte Preprocess: npm i -D typescript node-sass svelte-preprocess
  3. Create a svelte.config.js:
const sveltePreprocess = require('svelte-preprocess')

module.exports = {
  preprocess: sveltePreprocess()
}
  1. Restart Svelte Beta in VS Code
  2. Add lang="scss" to <style> tag in src/App.svelte
  3. Save file. Svelte Beta warning should appear on <script> tag

Expected behavior Expected Svelte Beta to not return any warnings or errors.

Screenshots SvelteWarning SvelteWarning001 SvelteWarning002 SvelteWarning003

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:closed
  • Created 3 years ago
  • Reactions:6
  • Comments:30 (12 by maintainers)

github_iconTop GitHub Comments

2reactions
jasonlyu123commented, Jun 3, 2020

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 require node-sass in a js file and run the file with node to see if there are any errors.

const nodeSass = require('node-sass')

console.log(nodeSass)
1reaction
dummdidummcommented, Jun 9, 2020

It is documented and the warning in the IDE does also hint at this.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found