Responsive webpack: avoid ".." in import statements

I am currently studying the reaction and thus es6 / es7 and webpack.

Based on the background in mostly python, I am annoyed by declarations with path attributes for import statements, i.e. use ../../in import statements. This means that if I transfer the file to another directory, I need to change the import instructions declared in the file.

The Python import statement does not have this problem. I would like to imitate this behavior (first find a specific directory for this path if you do not search in this other base directory) for example if I have a directory structure

myApp
    components
        component1.jsx
    stores
        store1.jsx
    views
        view1.jsx


node_modules
    react
    etc

in my view1.jsx I do not want to write

import Component1 from '../components/component1'

I want to write

import Component1 from 'components/component1'

or maybe even

import Component1 from 'myApp/components/component1'

, npm, .

webpack? ?

+2
2

@zerkms. resolve.modulesDirectories - .

+1

, , https://www.npmjs.com/package/future-require-loader. , ___filename.js___. : ___folder/filename.js___. , , , .

0

Source: https://habr.com/ru/post/1677516/


All Articles