Q
Q
quiplunar2020-06-29 12:57:23
JavaScript
quiplunar, 2020-06-29 12:57:23

Why doesn't websotrm see alias from webpack?

Webpack has the following alias for images:

alias: {
    assets: path.resolve(__dirname, './src/static/assets')
},


Referring to image in html:

5ef9ba9c32c8d687959073.png

And webstorm doesn't understand alias, and hence no autocomlit. But webpack builds everything fine:

5ef9bafcc0a2b844884648.png

Answer the question

In order to leave comments, you need to log in

4 answer(s)
A
Alexander Aksentiev, 2020-06-29
@quiplunar

jsconfig.json at the root of the project helps me

{ 
  "compilerOptions": {
    "baseUrl": "./",
    "paths": {
        "@/*": ["src/*"]
    }
  },
  "exclude": ["node_modules", "dist"]
}

S
SimBioT19, 2020-06-29
@SimBioT19

I have so. Add your alias and if needed restart WebStorm/PhpStorm

// webpack.config.js

const path = require('path');

function resolve(dir) {
  return path.resolve(__dirname, dir);
}

module.exports = {
  resolve: {
    extensions: ['.js', '.vue', '.json', '.ts'],
    alias: {
      '@': resolve('src/'),
    },
  },
};

A
Aetae, 2020-06-29
@Aetae

Perhaps he needs to explicitly point to the config:
5ef9c87e6a094647920370.png

L
LionG, 2020-12-01
@LionG

Understood. It was a WEB-38331 WebStorm bug. It has been fixed since version 2020.2.1.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question