Webpack: How do I bundle multiple javascript files into a single output file?

Viewed 26307

Suppose I have two files, main.js and app.js; how do I use Webpack to bundle both of them into one file: bundle.js?

3 Answers

You can pass an array of entries:

module.exports = {
   entry: ['./main.js', './app.js'],
   ...
};

Also, you can pass them as a CLI option:

webpack ./main.js ./app.js --config=webpack.config.js
Related