10

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'

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)?

hsz
  • 148,279
  • 62
  • 259
  • 315

1 Answers1

1

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. enter image description here

It was fixed with this version.

Tomasz Mularczyk
  • 34,501
  • 19
  • 112
  • 166