Path aliases for imports in RubyMine from Webpack

For the longest time, I just put up with RubyMine not finding imports that used webpack’s [resolve.modules](https://webpack.js.org/configuration/resolve/#resolvemodules) or [resolve.alias](https://webpack.js.org/configuration/resolve/#resolvealias) rather than relative paths.

RubyMine doesn’t like the files with the squiggly lines

rails/webapcker set the source_path directory

In case you’re using rails/webpacker, The modules are setup here:

const getModulePaths = () => {
  const result = new ConfigList()
  result.append('source', resolve(config.source_path))

Fix: Set the “Resource Root” on the “App” Directory

2020-07-08_20-22-39

Reference:

VS Code?

Another way is to let VSCode know how to resolve these aliases by adding a jsconfig.json file to your project at the root.

{
  "compilerOptions": {
    "paths": {
      "config/*": ["src/config/*"],
      "store/*": ["src/store/*"],
      "utils/*": ["src/utils/*"]
    }
  },
  "exclude": ["node_modules"]
}