I have been trying to import SCSS files with an absolute path for 2 days now...
My folder structure:
src
|--assets
|--|--styles
|--|--|--_variables.scss
|--UI
|--|--Layout.module.scss
I would like to import variables and functions from _variables.scss to Layout.module.scss using an absolute path to avoid my code from breaking when changing the folder structure.
I am using the live sass compiler extension in VS code which trows the error
Error: Can't find stylesheet to import.
when I try to import a scss file using an absolute path like @import 'src/assets/styles/variables' .
Relative paths work just fine
I tried several things:
Using the sass-loader
includePathsoption and including thesrcfolderUsing the webpack
module.resolveobject in the config file to add the src folder to the folder that will be searched when trying to import modules and then using the~assets/styles/variablespathUsing webpack
module.aliasobject in the webpack config file to define an alias for thesrcfolder and then use it like soStyles/variables
I looked up a lot of similar problems but neither of the solutions would help solve my problem. I would appreciate any possible solution!