Using webpack.config.js files for dependencies

Viewed 108

I have ModuleA, which depends on ModuleB. Both are in separate git repositories. ModuleB has a webpack.config.js file, and it works fine when I run webpack in ModuleB's directory. However, when I run webpack from ModuleA's directory, it seems like ModuleB's webpack.config.js isn't getting used.

Is this supposed to work, or are you supposed to pre-bundle ModuleB and point ModuleA at that bundle?

(Specifically, I'm using the webpack.config.js file to exclude a submodule in ModuleB.)

1 Answers

You should have only one webpack.config.js in a project. Inside that project, there can be various modules.

If Module A needs Module B. Then you should import Module B in module A.

E.g.

Module B (B.js)

export default class A{}

Module A (A.js)

import B from 'B';
Related