Toosick
Toosick

Reputation: 470

WebStorm Webpack Alias

My import import {keyGen} from 'shared/utils/gen' says cannot resolve symbol 'keyGen'. NPM package loading works just fine. The webpack builds also succeed and run just fine with the alias.

Here is our alias:

resolve: {
  extensions: ['.webpack-loader.js', '.web-loader.js', '.loader.js', '.js', '.styl'],

  alias: {
    shared: relativePath('./client/source/shared'),
    root: relativePath('./client/source'),
    config: relativePath('./')
  },

  modules: [relativePath('./node_modules')]
}

I made sure the correct Webpack config file is selected in the project settings. How do I get WebStorm to correctly identify Webpack aliases?

Upvotes: 0

Views: 750

Answers (1)

sam
sam

Reputation: 2820

If your config file exists on the same level with other source code files, try this:

alias: {
    shared: path.resolve('client/source/shared'),
    ...
}

Reference: https://webpack.js.org/configuration/resolve/

Upvotes: 0

Related Questions