C
C
Chingiz Mammadov2020-10-07 14:39:25
webpack
Chingiz Mammadov, 2020-10-07 14:39:25

How to properly write alias in webpack?

Hello. I'm trying to set an alias, but there is such a problem: Relative imports outside of src/ are not supported.
Code: '@Components': path.resolve(__dirname, './src/components/'). The bottom line is that the path goes beyond the project and displays such an error. What am I doing wrong? Thanks in advance.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2020-10-07
@z80b

Webpack wrote to you what you are doing wrong: "Relative imports outside of src/ are not supported
" it does not support relative import paths outside of a project.
If you are working on a nix system, I can advise you to make a link to the desired folder at the file system level, the link itself should naturally be placed within the project.
Well, i.e.: ln -s desired_dir/components project_dir/components

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question