How can I use scss in vue templates
See original GitHub issueHello, 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:
- Created 6 years ago
- Comments:10 (1 by maintainers)
Top 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 >
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
@benmccallum your problem is that you are using
type
instead oflang
.Should be:
Docs: https://vuejs.org/v2/guide/single-file-components.html
@ferllings did you install the dependencies as mentioned in the docs?
npm install sass-loader node-sass --save-dev