Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add single bundle mode for the build output #148

Merged
merged 1 commit into from
Aug 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/base.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand Down Expand Up @@ -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),
Expand Down
11 changes: 6 additions & 5 deletions src/dev.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}),
Expand All @@ -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) {
Expand All @@ -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
})
);
Expand Down
11 changes: 6 additions & 5 deletions src/dist.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}),
Expand All @@ -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"'
Expand All @@ -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
})
);
Expand Down
6 changes: 6 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down