I have the problem that mochapack does not seem to work together with the style resources loader.
packages that seem to produce the problem:
- "@vue/cli-plugin-unit-mocha": "~4.2.0",
- "vue-cli-plugin-style-resources-loader": "~0.1.4"
My vue.config.js
file:
const path = require("path");
module.exports = {
...
pluginOptions: {
"style-resources-loader": {
preProcessor: "scss",
patterns: [path.resolve(__dirname, "./src/assets/styles/*.scss")]
}
}
};
The single sass file that is included through the above config:
@import "~vue-select/src/scss/vue-select.scss";
It seems to load the vue-select.scss
correctly but then when interpreting this file it seems to loose its current directory and does not find the imported style.
Error log excerpt:
Module build failed (from ./node_modules/sass-loader/dist/cjs.js):
SassError: Can't find stylesheet to import.
╷
1 │ @import "global/variables";
│ ^^^^^^^^^^^^^^^^^^
╵
/node_modules/vue-select/src/scss/vue-select.scss 1:9 @import
/src/components/HelloWorld.vue 1:9
See full detail error message and code: https://github.com/petritz/food-calculator-web/runs/560575367
I'm using Mocha for my Unit Tests. After having the same issue, I noticed that I had to change my
vue.config.js
from:to:
EDIT: This might have some issues with local dev and production, so I had to change a couple of things:
sass-loader
to at least 10.1.0null-loader
to work around with CSS Preprocessor moduleschainWebpack
in thevue.config.js
to use thenull-loader
in mytest
andproduction
environmentsI found the answer in this open issue on the Vue CLI GitHub repo: https://github.com/vuejs/vue-cli/issues/4053#issuecomment-544641072