Answer the question
In order to leave comments, you need to log in
How to set correct relative path in scss in Vue CLI?
there is a project structure:
src
-assets
--img
---img.png
-style
--add.scss (imported ./screens/home.scss in it)
--screens
---home.scss
when trying to load a file from scss like this: background-image: url(../../assets/img.png) throws an error:
These relative modules were not found:
* ../../assets/img.png in ./node_modules/css-loader ??ref--8-oneOf-3-1!./node_modules/postcss-loader/src??ref--8-oneOf-3-2!./node_modules/sass-loader/dist/cjs.js?? ref--8-oneOf-3-3!./src/styles/app.scss
when accessing background-image: url(../assets/img.png) - everything is fine
how to configure resolve-url-loader and/or sass-resources-loader with vue CLI 3 to load images properly?
package.json
{
"dependencies": {
"core-js": "^2.6.5",
"resetcss": "^1.0.3",
"resolve-url-loader": "^3.1.0",
"sass-resources-loader": "^2.0.1",
"vue": "^2.6.10",
"vue-router": "^3.0.3",
"vuex": "^3.0.1"
},
"devDependencies": {
"@vue/cli-plugin-babel": "^3.11.0",
"@vue/cli-plugin-eslint": "^3.11.0",
"@vue/cli-service": "^3.11.0",
"babel-eslint": "^10.0.1",
"eslint": "^5.16.0",
"eslint-plugin-vue": "^5.0.0",
"sass": "^1.18.0",
"sass-loader": "^7.1.0",
"vue-template-compiler": "^2.6.10"
}
}
Answer the question
In order to leave comments, you need to log in
write like this
background: url('[email protected]/assets/img.png');
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question