I'm using vue2.0 rc.7 and vue-loader 9.5.
I cannot figure out how to use scss in vue file.
If i write like this <style lang="scss">, there will be an error saying Cannot resolve module 'scss' in xxxxx.

I can only use scss with<style lang="sass">
However, webstorm's inspection will not accept it.

So, how can i use scss syntax directly in *.vue
Hi @geekingin
thanks for filing this issue.
@LinusBorg Sorry for the broken format.
I'm not sure, here is my loaders in webpack config.
module: {
loaders: [{
test: /\.js$/,
loader: 'babel',
exclude: /node_modules/
}, {
test: /\.vue$/,
loader: 'vue'
}, {
test: /\.s[a|c]ss$/,
loader: 'style!css!sass'
}]
}
Is it right?
vue-loader infers the loader to use from the lang attribute's value, but there is no "scss-loader", only "sass-loader" (which handles both .scss and .sass styles).
So you have to tell vue-loader to use sass-loader for scss:
module: {
loaders: [{
test: /\.js$/,
loader: 'babel',
exclude: /node_modules/
}, {
test: /\.vue$/,
loader: 'vue'
}, {
test: /\.s[a|c]ss$/,
loader: 'style!css!sass'
}]
},
vue: {
loaders: {
scss: 'style!css!sass'
}
}
That's exactly what i'm looking for, thanks a lot!
great resolution!!! thanks!
trying this .. I get
Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
- configuration has an unknown property 'vue'. These properties are valid:
any ideas ?
You are using webpack 2, which changed how to pass config to loaders:
https://vue-loader.vuejs.org/en/configurations/advanced.html
More to the point for my fellow googler's looking for scss and Vue 2 config:
The vue config in webpack-simple works for lang="scss" (after installing sass-loader and node-sass), but it does not include the ExtractTextPlugin.
The newest Vue-Cli with webpack is missing the sass-loader in order for this to work.
Like mentioned above, you will be able to use
Most helpful comment
vue-loader infers the loader to use from the
langattribute's value, but there is no "scss-loader", only "sass-loader" (which handles both.scssand.sassstyles).So you have to tell vue-loader to use sass-loader for
scss: