Sebastian Sandqvist
Sebastian Sandqvist

Reputation: 1889

Split Webpack CommonsChunkPlugin Output into Multiple Files

I am using Webpack to bundle my clientside modules and would like to take advantage of parallel asset downloading. I would like html somewhat like this:

<script src="vendor/react.js">
<script src="vendor/underscore.js">
<script src="build/bundle.js">

Where bundle.js contains:

var React = require('react');
var _ = require('underscore');

Note that vendor/react.js and vendor/underscore.js would also be bundled by Webpack.

I know that the Webpack CommonsChunkPlugin can extract all the vendor modules and put them into a single common vendor.js file. Is it possible, though, to split that common output file into two or more output files?

Upvotes: 1

Views: 1114

Answers (1)

Sebastian Sandqvist
Sebastian Sandqvist

Reputation: 1889

After a bit more digging, I found an answer.

Soundcloud created a webpack plugin specifically for this purpose (see here) though it lacked support for splitting code in the node_modules folder. Another plugin based on it solved that problem and was trivial to set up.

Upvotes: 2

Related Questions