[Bug] imports do not work with sass-loader and stdin template
See original GitHub issue- I’d be willing to submit the fix
Describe the bug
I got the following webpack config for the sass-loader:
{
"loader": "sass-loader",
"options": {
"sourceMap": true,
"outputStyle": "expanded",
"implementation": {
"info": "dart-sass\t1.22.10\t(Sass Compiler)\t[Dart]\ndart2js\t2.4.1\t(Dart Compiler)\t[Dart]",
"types": {}
},
"data": "@import \"~assets/scss/_replacements/vuetify-main.scss\""
}
}
Error in ./node_modules/vuetify/src/components/VCalendar/mixins/calendar-with-events.sass
Module build failed (from ./node_modules/mini-css-extract-plugin/dist/loader.js): ModuleBuildError: Module build failed (from ./node_modules/sass-loader/dist/cjs.js): Can’t find stylesheet to import. ╷ 2 │ @import ‘vuetify-variables’; │ ^^^^^^^^^^^^^^^^^^^ ╵ app/assets/scss/_replacements/vuetify-main.scss 2:9 @import stdin 1:9 root stylesheet in about:/app/assets/scss/_replacements/vuetify-main.scss (line 2, column 9) at /app/node_modules/webpack/lib/NormalModule.js:316:20 at /app/node_modules/loader-runner/lib/LoaderRunner.js:367:11 at /app/node_modules/loader-runner/lib/LoaderRunner.js:233:18 at /app/node_modules/sass-loader/dist/index.js:89:7
I can try all variations of the import, but the sub-import in the imported file cannot be resolved.
**To Reproduce**
add an import in the stdin template for sass-loader (see above)
**Environment if relevant (please complete the following information):**
- OS: Linux on Docker
- Node version v12.14.1
- Mochapack version 2.0.0
- Webpack version 4.43.0
Thanks for giving me an idea. Is it the ~ in the import patH?
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (3 by maintainers)
Top GitHub Comments
@larixer: Thank you for the detailed explanation. It appears as if all my troubles were caused by using
--require
instead of--include
.In case anyone else encounters a similar issue here are a few more details:
Thank you again!
@josephlavin
The compilation is not
mochapack
issue at all. This can easily be seen if you update yourwebpack.mix.js
like this:add
webpack-node-externals
into your project via:npm install --save-dev webpack-node-externals
you should also addcanvas
, as it will be required byjsdom-global
later:npm install --save-dev canvas
and update your test script to:
Note you should use
--include
flag here, not--require
, require is invoked BEFOREwebpack
compilation and used to loadmocha
plugins, and--include
makes yoursetup.js
be a part of tests.