vue-cli: Sass-loader 8.0.0 not working with Vue-cli 3
Version
3.11.0
Environment info
Environment Info:
System:
OS: macOS 10.14.6
CPU: (8) x64 Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz
Binaries:
Node: 12.6.0 - /usr/local/bin/node
Yarn: 1.17.3 - /usr/local/bin/yarn
npm: 6.10.3 - /usr/local/bin/npm
Browsers:
Chrome: 76.0.3809.132
Firefox: 68.0.2
Safari: 12.1.2
npmPackages:
@3yourmind/vue-yodify: ^0.2.9 => 0.2.9
@vue/babel-helper-vue-jsx-merge-props: 1.0.0
@vue/babel-plugin-transform-vue-jsx: 1.0.0
@vue/babel-preset-app: ^3.11.0 => 3.11.0
@vue/babel-preset-jsx: 1.1.0
@vue/babel-sugar-functional-vue: 1.0.0
@vue/babel-sugar-inject-h: 1.0.0
@vue/babel-sugar-v-model: 1.0.0
@vue/babel-sugar-v-on: 1.1.0
@vue/cli-overlay: 3.11.0
@vue/cli-plugin-babel: ^3.11.0 => 3.11.0
@vue/cli-plugin-unit-jest: ^3.11.0 => 3.11.0
@vue/cli-service: ^3.11.0 => 3.11.0
@vue/cli-shared-utils: 3.11.0
@vue/component-compiler-utils: 3.0.0
@vue/eslint-config-prettier: ^5.0.0 => 5.0.0
@vue/preload-webpack-plugin: 1.1.1
@vue/test-utils: ^1.0.0-beta.29 => 1.0.0-beta.29
@vue/web-component-wrapper: 1.2.0
babel-helper-vue-jsx-merge-props: 2.0.3
eslint-plugin-vue: ^5.2.3 => 5.2.3
jest-serializer-vue: 2.0.2
typescript: ^3.6.2 => 3.6.2
vue: ^2.6.10 => 2.6.10
vue-autosize: ^1.0.2 => 1.0.2
vue-clickaway: ^2.2.2 => 2.2.2
vue-cropper: ^0.4.9 => 0.4.9
vue-echarts: ^4.0.3 => 4.0.3
vue-eslint-parser: ^6.0.4 => 6.0.4 (5.0.0)
vue-hot-reload-api: 2.3.3
vue-i18n: ^8.14.0 => 8.14.0
vue-jest: 3.0.4
vue-loader: 15.7.1
vue-meta: ^2.2.1 => 2.2.1
vue-multiselect: ^2.1.6 => 2.1.6
vue-popperjs: 2.0.4
vue-router: ^3.1.2 => 3.1.2
vue-style-loader: 4.1.2
vue-template-compiler: ^2.6.10 => 2.6.10
vue-template-es2015-compiler: 1.9.1
vue2-ace-editor: ^0.0.13 => 0.0.13
vuedraggable: ^2.23.0 => 2.23.0
vuex: ^3.1.1 => 3.1.1
vuex-router-sync: ^5.0.0 => 5.0.0
npmGlobalPackages:
@vue/cli: 3.11.0
Steps to reproduce
Install Sass-loader 8.0.0 and try to configure it to prependData in the vue.config.js - this does not work.
What is expected?
This is working using v7.3.1 of sass-loader
css: {
loaderOptions: {
sass: {
data: "@import '~::shared/assets/variables.scss';",
},
},
},
What is actually happening?
This is not working using version 8.0.0:
css: {
loaderOptions: {
sass: {
prependData: "@import '~::shared/assets/variables.scss';",
},
},
},
I tried solving this using the chain webpack interface but didn’t have much luck.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 13
- Comments: 39 (6 by maintainers)
CLI v3 works with sass-loader v7 only at the moment. You can downgrade it for now.
With CLI v4 + sass-loader v8 it’s
prependData
.Just wanted to mention:
I’m using
CLI v3.11.0
,Node v12.10.0
andsass-loader v8.0.0
and it’s working without any issues in my project with the config from the new rc docs.Note: the
~
is not needed?Should be replaced prependData with additionalData.
This is how it works:
module.exports = { css: { loaderOptions: { scss: { additionalData :
@import "@/assets/styles/styles.scss";
}, }, } };It doesn’t work like that: module.exports = { css: { loaderOptions: { scss: { prependData :
@import "@/assets/styles/styles.scss";
}, }, } };prependData
works for me with sass-loader v8. Please provide a valid reproduction.@pdoria, well as I said it works (my sass-loader is v7.3.1) but that not’s the point. The vue-cli release notes, and that prominent yellow warning, say to update sass-loader to v8.
опять трансгендерные олени-смузихлебы на самокатах все сломали
I’m just a simple regular user of vue-cli. I updated my project today to 4.0.1 but I get a yellow warning on
npm run serve
saying “A new version of sass-loader is available. Please upgrade for best experience.” So I upgrade sass-loader@7.3.1->8.0.0 but then I get crashes same as @pdoria above.I added that css stanza to my vue-config.js but it does not fix the problem.
This bug should be re-opened and the title changed to Vue-cli 4.
Here’s a definitive solution to those who have run into this problem:
sass-loader
to 8.0+vue.config.js
file/deep/
selector if you have any. Apparently it’s deprecated. Luckily I could do this without too much trouble.if you use material or something else which uses sass down in the modules you have to add one line to the above :
module.exports = { lintOnSave: false, css: { loaderOptions: { sass: { prependData:
@import '@/assets/sass/_theme.scss';
, sassOptions: { includePaths: [path.resolve(__dirname, “node_modules”)] } } } } };This works for me… just put
;
at the end of the file pathhttps://next.cli.vuejs.org/guide/css.html#passing-options-to-pre-processor-loaders
@kagz Place it in
vue.config.js
Getting the same error when using sass-loader 8 with vuetilfy and electron
I updated now everything, my global vue cli (don’t know whether it is needed or not) and the sass-loader to 8.0.0. Now I got this error:
So this is now the problem with mixed sass and scss, but first I installed sass-loader and second I already used the loaderOptions scss, and not sass.
I already commented here, couple of days ago: https://github.com/vuejs/vue-cli/issues/4116
Duplicate of https://github.com/vuejs/vue-cli/issues/4513 (kinda)