Skip to content

Commit

Permalink
feat(bundler): allow creating a bundle with common code
Browse files Browse the repository at this point in the history
  • Loading branch information
satya164 committed Nov 22, 2016
1 parent d2fbc70 commit 317b10f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ The `--production` option performs minification on the resulting bundle. You can
You can provide multiple entry points as arguments. In that case, you can use `[name]` to get the name of the entry point while specifying an output file,

```sh
quik --bundle file1.js file2.js --output [name].bundle.js
quik --bundle file1.js file2.js --output [name].bundle.js --common common.bundle.js
```

Sourcemap files are automatically generated when generating bundles.
Expand Down
6 changes: 6 additions & 0 deletions src/configure-bundler.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ export default async function(options) {
filename: OUTPUTFILE,
sourceMapFilename: OUTPUTFILE + '.map',
},
plugins: options.common ? [
new webpack.optimize.CommonsChunkPlugin({
name: options.common,
filename: options.common,
}),
] : null,
entry,
}));
}
5 changes: 5 additions & 0 deletions src/quik-cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ const argv = yargs
type: 'string',
description: 'Name of the output file',
},
common: {
type: 'string',
description: 'Name of file to contain common code in case of multiple entries',
},
production: {
type: 'boolean',
default: false,
Expand Down Expand Up @@ -84,6 +88,7 @@ if (argv.init) {
bundle({
root: process.cwd(),
entry: argv.bundle.map(it => './' + it),
common: argv.common,
output: argv.output,
production: argv.production,
sourcemaps: argv.sourcemaps,
Expand Down

0 comments on commit 317b10f

Please sign in to comment.