React webpack path resolution problem

I configured aliases under resolve.alias:

clipboard.png

clipboard.png

tsx():

clipboard.png

scss():
clipboard.png

there is no problem, and the style loads normally. What is the problem?
Thank you very much.


The

project is a typescript project, and the module cannot be resolved after an alias has been added to webpack.config.js.
at this point, you also need to configure path resolution in tsconfig.json and change allowJs to true.
example:
webpack.config.js:

"compilerOptions": {
    "baseUrl": ".",
    ...
    "allowJs": true,
    "paths": {
      "@src/*": ["./src/*"]
    }
    ...
  }
Menu