I am trying to import a scss file within my VueJS project, where it will then compile and thus be able to use with my project. However, I need some help, as at present it si
to make it simple just use this trick
vue.config.js
(if it was not auto-created by vue-cli
when you were creating your project)module.exports = {
css: {
loaderOptions: {
sass: {
prependData: `
@import "@/assets/scss/main.scss";
`
}
}
}
};
@
means src
dir this means that @/assets
is the same as src/assets
main.scss
file, where you include all of you sub scss files if you want to know how it is made, take a look here it is really cool to work with itprependData
may not work or throw an error the reason why I used these is because I am using "sass-loader": "^8.0.2"
. here are some useful information
- on
"sass-loader": "^7.*.*"
try to usedata
- on
"sass-loader": "^8.0.2"
try to useprependData
- on
"sass-loader": "^9.0.0"
try to useadditionalData
vue.config.js
vuetify
it may throw an error, so make sure that you match the processor name with the extension, like if you have .scss
files you will need to use these configs scss: { //the change was made here (match the option name with file extension)
prependData: `
@import "@/assets/scss/main.scss";
`
}
if you are using .sass
file use these configs
sass: { //the change was made here (match the option name with file extension)
prependData: `
@import "@/assets/scss/main.sass";
`
}