P
P
psyhO_octopus2015-08-06 15:43:04
JavaScript
psyhO_octopus, 2015-08-06 15:43:04

How to properly configure modulesDirectories in webpack?

File structure

app/
    components/
        ...
        Button/
            Button.jsx
webpack.config.js

I would like to be able to wire this component in another component without a relative path i.e. no,
var Button = require('../Button/Button.jsx);
but like this:
var Button = require('Button/Button.jsx);
To do this, webpack has the resolve.modulesDirectories setting, but how to set it up correctly is not entirely clear. Tried like this:
resolve: {
    modulesDirectories: ['web_modules', 'node_modules', 'components']
}
resolve: {
    modulesDirectories: ['web_modules', 'node_modules', './app/components']
}

but not working

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question