diff --git a/src/base.config.ts b/src/base.config.ts index a3a58368..0d747c75 100644 --- a/src/base.config.ts +++ b/src/base.config.ts @@ -138,11 +138,11 @@ export default function webpackConfigFactory(args: any): WebpackConfiguration { const customTransformers: any[] = []; - if (lazyModules.length > 0) { + if (lazyModules.length > 0 && !args.singleBundle) { customTransformers.push(registryTransformer(basePath, lazyModules)); } - if (!args.legacy) { + if (!args.legacy && !args.singleBundle) { customTransformers.push(importTransformer(basePath, args.bundles)); } @@ -233,6 +233,10 @@ export default function webpackConfigFactory(args: any): WebpackConfiguration { devtool: 'source-map', watchOptions: { ignored: /node_modules/ }, plugins: removeEmpty([ + args.singleBundle && + new webpack.optimize.LimitChunkCountPlugin({ + maxChunks: 1 + }), new CssModulePlugin(basePath), new AutoRequireWebpackPlugin(mainEntry), new webpack.BannerPlugin(banner), diff --git a/src/dev.config.ts b/src/dev.config.ts index eb8f398d..34fb6e87 100644 --- a/src/dev.config.ts +++ b/src/dev.config.ts @@ -24,7 +24,7 @@ function webpackConfig(args: any): webpack.Configuration { new ManifestPlugin(), new HtmlWebpackPlugin({ inject: true, - chunks: ['runtime', 'main'], + chunks: args.singleBundle ? ['main'] : ['runtime', 'main'], meta: manifest ? { 'mobile-web-app-capable': 'yes' } : {}, template: 'src/index.html' }), @@ -37,9 +37,10 @@ function webpackConfig(args: any): webpack.Configuration { : manifest.icons }), new CleanWebpackPlugin(['dev'], { root: output.path, verbose: false }), - new webpack.optimize.CommonsChunkPlugin({ - name: 'runtime' - }) + !args.singleBundle && + new webpack.optimize.CommonsChunkPlugin({ + name: 'runtime' + }) ].filter((item) => item); if (serviceWorker) { @@ -57,7 +58,7 @@ function webpackConfig(args: any): webpack.Configuration { config.plugins.push( new BuildTimeRender({ ...args['build-time-render'], - entries: ['runtime', ...Object.keys(config.entry!)], + entries: args.singleBundle ? Object.keys(config.entry!) : ['runtime', ...Object.keys(config.entry!)], useManifest: true }) ); diff --git a/src/dist.config.ts b/src/dist.config.ts index d4a02c71..86e8c83f 100644 --- a/src/dist.config.ts +++ b/src/dist.config.ts @@ -36,7 +36,7 @@ function webpackConfig(args: any): webpack.Configuration { }), new HtmlWebpackPlugin({ inject: true, - chunks: ['runtime', 'main'], + chunks: args.singleBundle ? ['main'] : ['runtime', 'main'], meta: manifest ? { 'mobile-web-app-capable': 'yes' } : {}, template: 'src/index.html' }), @@ -51,9 +51,10 @@ function webpackConfig(args: any): webpack.Configuration { new UglifyJsPlugin({ sourceMap: true, cache: true }), new WebpackChunkHash(), new CleanWebpackPlugin(['dist'], { root: output.path, verbose: false }), - new webpack.optimize.CommonsChunkPlugin({ - name: 'runtime' - }), + !args.singleBundle && + new webpack.optimize.CommonsChunkPlugin({ + name: 'runtime' + }), new webpack.DefinePlugin({ 'process.env': { NODE_ENV: '"production"' @@ -76,7 +77,7 @@ function webpackConfig(args: any): webpack.Configuration { config.plugins.push( new BuildTimeRender({ ...args['build-time-render'], - entries: ['runtime', ...Object.keys(config.entry!)], + entries: args.singleBundle ? Object.keys(config.entry!) : ['runtime', ...Object.keys(config.entry!)], useManifest: true }) ); diff --git a/src/main.ts b/src/main.ts index df481cb4..7e1197ad 100644 --- a/src/main.ts +++ b/src/main.ts @@ -189,6 +189,12 @@ const command: Command = { type: 'number' }); + options('single-bundle', { + describe: 'Limits the built output to single bundle', + default: false, + type: 'boolean' + }); + options('legacy', { describe: 'build app with legacy browser support', alias: 'l',