Skip to content

Commit 317b10f

Browse files
committed
feat(bundler): allow creating a bundle with common code
1 parent d2fbc70 commit 317b10f

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ The `--production` option performs minification on the resulting bundle. You can
9797
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,
9898

9999
```sh
100-
quik --bundle file1.js file2.js --output [name].bundle.js
100+
quik --bundle file1.js file2.js --output [name].bundle.js --common common.bundle.js
101101
```
102102

103103
Sourcemap files are automatically generated when generating bundles.

src/configure-bundler.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ export default async function(options) {
3333
filename: OUTPUTFILE,
3434
sourceMapFilename: OUTPUTFILE + '.map',
3535
},
36+
plugins: options.common ? [
37+
new webpack.optimize.CommonsChunkPlugin({
38+
name: options.common,
39+
filename: options.common,
40+
}),
41+
] : null,
3642
entry,
3743
}));
3844
}

src/quik-cli.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ const argv = yargs
4444
type: 'string',
4545
description: 'Name of the output file',
4646
},
47+
common: {
48+
type: 'string',
49+
description: 'Name of file to contain common code in case of multiple entries',
50+
},
4751
production: {
4852
type: 'boolean',
4953
default: false,
@@ -84,6 +88,7 @@ if (argv.init) {
8488
bundle({
8589
root: process.cwd(),
8690
entry: argv.bundle.map(it => './' + it),
91+
common: argv.common,
8792
output: argv.output,
8893
production: argv.production,
8994
sourcemaps: argv.sourcemaps,

0 commit comments

Comments
 (0)