Closed Goldziher closed 5 years ago
It's working on vue-cli 4.0.0-rc.0
Duplicate of https://github.com/vuejs/vue-cli/issues/4513 (kinda)
prependData
works for me with sass-loader v8. Please provide a valid reproduction.
I can confirm this issue. sass-loader does not work with version 8.0.0. and vue cli 3.10.0
I get a slightly different error when trying to upgrade to sass-loader
8.0:
11:28:22 AM: ValidationError: Invalid options object. Sass Loader has been initialised using an options object that does not match the API schema.
11:28:22 AM: - options has an unknown property 'indentedSyntax'. These properties are valid:
11:28:22 AM: object { implementation?, sassOptions?, prependData?, sourceMap?, webpackImporter? }
11:28:22 AM: at validate (/opt/build/repo/node_modules/sass-loader/node_modules/schema-utils/dist/validate.js:49:11)
11:28:22 AM: at Object.loader (/opt/build/repo/node_modules/sass-loader/dist/index.js:36:28)
11:28:22 AM: at runLoaders (/opt/build/repo/node_modules/webpack/lib/NormalModule.js:313:20)
11:28:22 AM: at /opt/build/repo/node_modules/loader-runner/lib/LoaderRunner.js:367:11
11:28:22 AM: at /opt/build/repo/node_modules/loader-runner/lib/LoaderRunner.js:233:18
11:28:22 AM: at runSyncOrAsync (/opt/build/repo/node_modules/loader-runner/lib/LoaderRunner.js:143:3)
11:28:22 AM: at iterateNormalLoaders (/opt/build/repo/node_modules/loader-runner/lib/LoaderRunner.js:232:2)
11:28:22 AM: at Array.<anonymous> (/opt/build/repo/node_modules/loader-runner/lib/LoaderRunner.js:205:4)
11:28:22 AM: at Storage.finished (/opt/build/repo/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:43:16)
11:28:22 AM: at provider (/opt/build/repo/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:79:9)
11:28:22 AM: at /opt/build/repo/node_modules/graceful-fs/graceful-fs.js:115:16
11:28:22 AM: at FSReqWrap.readFileAfterClose [as oncomplete] (internal/fs/read_file_context.js:53:3)
It looks like it's complaining about this line now in Sass 8.0.
Supported in 4.0.0-rc.3
Still got problems with newest versions of Vuetify and sass-loader:
./node_modules/vuetify/src/components/VInput/VInput.sass (./node_modules/css-loader??ref--9-oneOf-3-1!./node_modules/postcss-loader/src??ref--9-oneOf-3-2!./node_modules/sass-loader/dist/cjs.js??ref--9-oneOf-3-3!./node_modules/vuetify/src/components/VInput/VInput.sass)
Module build failed (from ./node_modules/sass-loader/dist/cjs.js):
ValidationError: Invalid options object. Sass Loader has been initialised using an options object that does not match the API schema.
- options has an unknown property 'indentedSyntax'. These properties are valid:
object { implementation?, sassOptions?, prependData?, sourceMap?, webpackImporter? }
at validate (C:\Projekte\urania\node_modules\sass-loader\node_modules\schema-utils\dist\validate.js:50:11)
at Object.loader (C:\Projekte\urania\node_modules\sass-loader\dist\index.js:36:28)
Here is my pacakge.json file: https://gist.github.com/Chris2011/b4a5f0651f6abb09064a356848624655
First I had m own config part:
css: {
loaderOptions: {
scss: {
data: `@import '@/assets/base.scss';`,
},
},
},
But then I got the error with the unknown property data
so I commented it out. But now I got this error.
For global I use @vue/cli 3.11.0. In my project I also tried @vue/cli-service 4.0.0-rc.6, still no luck. When I switch to rc.6 and I uncomment the css loaderOptions, I got this error:
./node_modules/vuetify/src/components/VSheet/VSheet.sass (./node_modules/css-loader/dist/cjs.js??ref--9-oneOf-3-1!./node_modules/postcss-loader/src??ref--9-oneOf-3-2!./node_modules/sass-loader/dist/cjs.js??ref--9-oneOf-3-3!./node_modules/vuetify/src/components/VSheet/VSheet.sass)
Module build failed (from ./node_modules/sass-loader/dist/cjs.js):
ValidationError: Invalid options object. Sass Loader has been initialised using an options object that does not match the API schema.
- options has an unknown property 'data'. These properties are valid:
object { implementation?, sassOptions?, prependData?, sourceMap?, webpackImporter? }
at validate (C:\Projekte\urania\node_modules\sass-loader\node_modules\schema-utils\dist\validate.js:50:11)
at Object.loader (C:\Projekte\urania\node_modules\sass-loader\dist\index.js:36:28)
Does anyone of the commenters solved that problem?
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
.
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:
Failed to compile.
./node_modules/vuetify/src/components/VAlert/VAlert.sass (./node_modules/css-loader/dist/cjs.js??ref--9-oneOf-3-1!./node_modules/postcss-loader/src??ref--9-oneOf-3-2!./node_modules/sass-loader/dist/cjs.js??ref--9-oneOf-3-3!./node_modules/vuetify/src/components/VAlert/VAlert.sass)
Module build failed (from ./node_modules/sass-loader/dist/cjs.js):
SassError: semicolons aren't allowed in the indented syntax.
╷
1 │ @import '~@/assets/base.scss';
│ ^
╵
C:\Projekte\urania\node_modules\vuetify\src\components\VAlert\VAlert.sass 1:30 root stylesheet
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
My case is, I need a newer version of vuetify, before I got the problems, I used 1.5.*, but it has less features so I updated vuetify for that. Just to let you know what I need.
Got it. It's a bug. See https://github.com/vuejs/vue-cli/pull/4637 I'll soon release a new version.
Next time, please open a new issue with a runnable reproduction; that will help us locate the problem more quickly. It's pure luck for me to find the bug by just looking at the error message this time…
Ok, thx for your help and sry for the inconvenience :)
Fixed in rc.7.
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
and sass-loader v8.0.0
and it's working without any issues in my project with the config from the new rc docs.
module.exports = {
css: {
loaderOptions: {
scss: {
prependData: `
@import "~@/scss/_variables.scss";
@import "~@/scss/_mixins.scss";
`
}
}
}
};
Note: the ~
is not needed?
@sodatea thx for the fix. It is working now :)
Getting the same error when using sass-loader 8 with vuetilfy and electron
ERROR in ./node_modules/vuetify/src/components/VDataTable/VDataTable.sass (./node_modules/css-loader!./node_modules/sass-loader/dist/cjs.js?indentedSyntax!./node_modules/vuetify/src/components/VDataTable/VDataTable.sass)
Module build failed (from ./node_modules/sass-loader/dist/cjs.js):
ValidationError: Invalid options object. Sass Loader has been initialised using an options object that does not match the API schema.
- options has an unknown property 'indentedSyntax'. These properties are valid:
object { implementation?, sassOptions?, prependData?, sourceMap?, webpackImporter? }
at validate (/Users/varun/Documents/GitHub/gym-management/node_modules/sass-loader/node_modules/schema-utils/dist/validate.js:50:11)
at Object.loader (/Users/varun/Documents/GitHub/gym-management/node_modules/sass-loader/dist/index.js:36:28)
@ ./node_modules/vuetify/src/components/VDataTable/VDataTable.sass 4:14-127 14:3-18:5 15:22-135
@ ./node_modules/vuetify/lib/components/VDataTable/VDataTable.js
@ ./node_modules/vuetify/lib/components/VDataTable/index.js
@ ./node_modules/vuetify/lib/components/index.js
@ ./node_modules/vuetify/lib/index.js
@ ./src/renderer/plugins/vuetify.js
@ ./src/renderer/main.js
@ multi ./.electron-vue/dev-client ./src/renderer/main.js
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.module.exports = { css: { loaderOptions: { scss: { prependData: ` @import "~@/scss/_variables.scss"; @import "~@/scss/_mixins.scss"; ` } } } };
Note: the
~
is not needed?
Where exactly is this change to be made? Thanks! btw: using CLI v4.0.1, Node v10.16.0, sass-loader v8.0.0
getting a bunch of this (or similar):
error in ./node_modules/vuetify/src/components/VColorPicker/VColorPicker.sass
Module build failed (from ./node_modules/sass-loader/dist/cjs.js):
ValidationError: Invalid options object. Sass Loader has been initialised using an options object that does not match the API schema.
- options has an unknown property 'data'. These properties are valid:
object { implementation?, sassOptions?, prependData?, sourceMap?, webpackImporter? }
at validate (/home/doria/VSCProjects/Vue-CLI3/todo/node_modules/sass-loader/node_modules/schema-utils/dist/validate.js:50:11)
at Object.loader (/home/doria/VSCProjects/Vue-CLI3/todo/node_modules/sass-loader/dist/index.js:36:28)
@ ./node_modules/vuetify/src/components/VColorPicker/VColorPicker.sass 4:14-211 14:3-18:5 15:22-219
@ ./node_modules/vuetify/lib/components/VColorPicker/VColorPicker.js
@ ./node_modules/vuetify/lib/components/VColorPicker/index.js
@ ./node_modules/vuetify/lib/components/index.js
@ ./node_modules/vuetify/lib/index.js
@ ./src/plugins/vuetify.js
@ ./src/main.js
@ multi (webpack)-dev-server/client?http://192.168.1.8:8080/sockjs-node (webpack)/hot/dev-server.js ./src/main.js
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.
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.
don't upgrade! It (vuetify) only works with sass-loader 7.1.0! (just tested it and works with 7.1 ;) )
@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.
module.exports = {
css: {
loaderOptions: {
sass: {
prependData: ` @import '@/assets/sass/_theme.scss';`
}
}
},
}
This works for me.. just put ;
at the end of the file path
module.exports = { css: { loaderOptions: { sass: { prependData: ` @import '@/assets/sass/_theme.scss';` } } }, }
This works for me.. just put
;
at the end of the file path
where exactly do you place those codes
module.exports = { css: { loaderOptions: { sass: { prependData: ` @import '@/assets/sass/_theme.scss';` } } }, }
This works for me.. just put
;
at the end of the file pathwhere exactly do you place those codes
@kagz
Place it in vue.config.js
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")]
}
}
}
}
};
Here's a definitive solution to those who have run into this problem:
upgrade your Vue CLI to 4.0+:
npm update -g @vue/cli
# OR
yarn global upgrade --latest @vue/cli
upgrade your sass-loader
to 8.0+
npm update sass-loader
# OR
yarn upgrade --latest sass-loader
update your vue.config.js
file
module.exports = {
css: {
loaderOptions: {
// old
sass: {
data: `@import "@/styles/_global.scss";`,
},
// new
sass: {
prependData: `@import "@/styles/_global.sass"`, // change to *.sass; remove semi-colon
},
scss: { // separate one for scss
prependData: `@import "@/styles/_global.scss"`, // this is .scss
},
},
},
// ...
}
remove /deep/
selector if you have any. Apparently it's deprecated. Luckily I could do this without too much trouble.
@jaiko86 - thanks man, that helped a lot. I had to add semicolon to make the scss work, this is my working config - also with node modules scss files import enabled.
module.exports = {
css: {
loaderOptions: {
sass: {
sassOptions: {
includePaths: [
'./node_modules'
]
},
prependData: `@import "@/styles/global.scss";`,
},
},
},
};
Hi, Is this working for production build? . I am facing the issue with production as .scss modules are not extracted while building.
The solution provided by @jaiko86 is not working for me... I'm using "sass-loader": "^8.0.2"
with @vue/cli-service v4.3.1
css: {
loaderOptions: {
sass: {
prependData: `@import "@/styles/global.scss";`,
}
}
}
I also tried to downgrade sass-loader to 7.3.1, but with no luck
The solution provided by @jaiko86 is not working for me... I'm using
"sass-loader": "^8.0.2"
with@vue/cli-service v4.3.1
css: { loaderOptions: { sass: { prependData: `@import "@/styles/global.scss";`, } } }
I also tried to downgrade sass-loader to 7.3.1, but with no luck
Hi, i have the same version and it's working using the @jaiko86 configuration, but you should also include sassOptions attribute to load _nodemodule directory just like @JakubHromada example when your scss files are imported from installed components. This is my configuration:
....
css: {
loaderOptions: {
sass: {
sassOptions: {
includePaths: [
'./node_modules'
]
},
prependData: `@import "~@/style/sass/main.scss"`
},
},
}
.....
where main.scss has imports from _nodemodules path
Getting the same error when using sass-loader 8 with vuetilfy and electron
ERROR in ./node_modules/vuetify/src/components/VDataTable/VDataTable.sass (./node_modules/css-loader!./node_modules/sass-loader/dist/cjs.js?indentedSyntax!./node_modules/vuetify/src/components/VDataTable/VDataTable.sass) Module build failed (from ./node_modules/sass-loader/dist/cjs.js): ValidationError: Invalid options object. Sass Loader has been initialised using an options object that does not match the API schema. - options has an unknown property 'indentedSyntax'. These properties are valid: object { implementation?, sassOptions?, prependData?, sourceMap?, webpackImporter? } at validate (/Users/varun/Documents/GitHub/gym-management/node_modules/sass-loader/node_modules/schema-utils/dist/validate.js:50:11) at Object.loader (/Users/varun/Documents/GitHub/gym-management/node_modules/sass-loader/dist/index.js:36:28) @ ./node_modules/vuetify/src/components/VDataTable/VDataTable.sass 4:14-127 14:3-18:5 15:22-135 @ ./node_modules/vuetify/lib/components/VDataTable/VDataTable.js @ ./node_modules/vuetify/lib/components/VDataTable/index.js @ ./node_modules/vuetify/lib/components/index.js @ ./node_modules/vuetify/lib/index.js @ ./src/renderer/plugins/vuetify.js @ ./src/renderer/main.js @ multi ./.electron-vue/dev-client ./src/renderer/main.js
Hey did you find a fix for electron?
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";
},
},
}
};
problem solved for me with sass-loader 10.0.4 with additionalData not prependData
module.exports ={ css: { loaderOptions: { sass: { additionalData: "@import '@/sass/main.scss';", }, }, }, }
I have no idea how this is working for you guys. I have tried every combination to no avail. Semi-colon, no semi-colon. data, additionalData, prependData. sass, scss.
This is how it currently looks and isn't working:
module.exports = {
pluginOptions: {
electronBuilder: {
nodeIntegration: true
}
},
css: {
loaderOptions: {
scss: {
additionalData: `@import "@/theme/components/_tab-view.scss";`
}
}
}
}
These are my dependencies:
"dependencies": {
"@fortawesome/fontawesome-free": "^5.15.1",
"core-js": "^3.6.5",
"nedb": "^1.8.0",
"path": "^0.12.7",
"reflect-metadata": "^0.1.13",
"vue": "^2.6.11",
"vue-class-component": "^7.2.3",
"vue-property-decorator": "^8.4.2",
"vue-router": "^3.2.0",
"vuex": "^3.4.0",
"vuex-class": "^0.3.2"
},
"devDependencies": {
"@types/electron-devtools-installer": "^2.2.0",
"@types/jest": "^24.0.19",
"@types/nedb": "^1.8.11",
"@typescript-eslint/eslint-plugin": "^2.33.0",
"@typescript-eslint/parser": "^2.33.0",
"@vue/cli-plugin-babel": "~4.5.0",
"@vue/cli-plugin-e2e-cypress": "~4.5.0",
"@vue/cli-plugin-eslint": "~4.5.0",
"@vue/cli-plugin-router": "~4.5.0",
"@vue/cli-plugin-typescript": "~4.5.0",
"@vue/cli-plugin-unit-jest": "~4.5.0",
"@vue/cli-plugin-vuex": "~4.5.0",
"@vue/cli-service": "~4.5.0",
"@vue/eslint-config-typescript": "^5.0.2",
"@vue/test-utils": "^1.0.3",
"electron": "^9.0.0",
"electron-devtools-installer": "^3.1.0",
"eslint": "^6.7.2",
"eslint-plugin-vue": "^6.2.2",
"node-sass": "^4.12.0",
"sass-loader": "^8.0.2",
"typescript": "~3.9.3",
"vue-cli-plugin-electron-builder": "~2.0.0-rc.5",
"vue-template-compiler": "^2.6.11",
"vuex-module-decorators": "^1.0.1"
}
I tried to just @import the SCSS file into the
Version
3.11.0
Environment info
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
What is actually happening?
This is not working using version 8.0.0:
I tried solving this using the chain webpack interface but didn't have much luck.