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.

How can I use scss in vue templates

See original GitHub issue

Hello, I’m trying to use scss in my components.

It works fine if I import a scss file

<style lang="scss" scoped>
  @import "../../assets/app.scss"
</style>

But if I use the scss code directly webpack doesn’t recognise it:

<style lang="scss" scoped>
nav {
  background-color: $nav-dark;
  color: $white;
  width: 15rem;
    a {
      color: $white;
      width: 100%;
    }
}
</style>

Invalid CSS after "nav": expected 1 selector or at-rule, was "{"

I installed node-sass and sass-loader Did I miss anything? Thanks for your help.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:10 (1 by maintainers)

github_iconTop GitHub Comments

35reactions
PierBovercommented, Jul 20, 2017

@benmccallum your problem is that you are using type instead of lang.

<style type="scss" scoped>

Should be:

<style lang="scss" scoped>

Docs: https://vuejs.org/v2/guide/single-file-components.html

21reactions
maxmiltoncommented, Jul 12, 2017

@ferllings did you install the dependencies as mentioned in the docs? npm install sass-loader node-sass --save-dev

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to use SCSS with Vue.js Single File Components
Find out how to enable SCSS into your Vue.js components.
Read more >
Using Pre-Processors - Vue Loader - Vue.js
It will automatically infer the proper loaders to use based on the lang attribute of a language block and the rules in your...
Read more >
Using sass variables in a VueJS component - Stack Overflow
Importing the _variables.scss in every component seems to be the only solution I've found so far (it should work, according to this issue)....
Read more >
Vue 3 - setting up global Sass/SCSS variables - WebDevEtc
If you have the Vue CLI tool, just run vue create scss and select Vue 3. There is an option to set up...
Read more >
Vue - Mixing SASS with SCSS, with Vuetify as an Example
Import in your root Vue template file (e.g. App.vue), either through the script section, the style section, or a style link tag. Use...
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