With webpack configuration it's possible to specify root of the resolving component:
resolve: {
root: [ path.join(__dirname, './src/') ],
extensions: ['', '.js', '.scss']
},
Now it is possible to import SASS file from ./src/
using tilde:
@import '~variables';
This import path will be resolved as ./src/variables
and everything works fine.
However IntelliJ doesn't recognize it properly and reports:
Cannot resolve file '~variables'
Is it possible somehow to configure this IDE to add extra resolve path (by default it resolves only from node_modules
directory)?
With current version of Webstorm it is possible to set webpack configuration, which will enable recognize path aliases across the project:
here is the answer where I specify how to set it.
It recognize imports inside scss with tildes as well.
It works in my project where I also use webpack aliases and scss
imports.
It was fixed with this version.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With