Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IntelliJ cannot resolve webpack aliased path

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

like image 502
hsz Avatar asked Jul 04 '16 20:07

hsz


1 Answers

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.

like image 163
Tomasz Mularczyk Avatar answered Nov 17 '22 02:11

Tomasz Mularczyk