A
A
Andrey Dyrkov2018-03-22 08:05:05
webpack
Andrey Dyrkov, 2018-03-22 08:05:05

How to set up alias in webpack for easy connection of modules?

I have a project, its structure is something like this

src/
----/components
--------/header
------------header.js
------------header.scss
----index.js

index.js is an entry describing dependencies
import 'components/header/header.js'; //1
import 'header/header'; //2

The 1st connection option is normal, and the second one I managed to do by adding the appropriate entries to resolve.modules and resolve.extensions.
How do I set up webpack, or at least alias, so that instead of header/header I include modules just like header.
PS: there are a lot of modules and it's not a tempting idea to prescribe stupidly in alias replacing header/header with header)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
tvelforce, 2019-02-14
@tvelforce

alias: {
  '@': path.join(__dirname, '../'),
  '@platform': path.join(__dirname, '../platform/')
  '@header': path.join(__dirname, '../platform/header')
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question