Skip to content

Commit

Permalink
new: Add new --parallel option. (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
milesj committed Mar 24, 2020
1 parent 260f365 commit 8120201
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 2 deletions.
16 changes: 16 additions & 0 deletions packages/config-webpack/src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,19 @@ export function getFavIcon(srcPath: string): string {

return favicon;
}

export function getParallelValue(value: boolean | string | number | undefined): boolean | number {
if (value === undefined) {
return true;
}

if (value === 'true') {
return true;
}

if (value === 'false' || value === '') {
return false;
}

return Number(value || 1);
}
6 changes: 4 additions & 2 deletions packages/config-webpack/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@ import {
GQL_EXT_PATTERN,
TJSX_EXT_PATTERN,
} from '@airbnb/nimbus-common';
import { PORT, ROOT, PROD, getESMAliases, getFavIcon } from './helpers';
import { PORT, ROOT, PROD, getESMAliases, getFavIcon, getParallelValue } from './helpers';

export interface WebpackOptions {
analyzeBundle?: boolean;
buildFolder?: string;
parallel?: boolean | string | number;
port?: string | number;
react?: boolean;
sourceMaps?: boolean;
Expand All @@ -28,6 +29,7 @@ export interface WebpackOptions {
export function getConfig({
analyzeBundle = false,
buildFolder = 'public',
parallel = true,
port = PORT,
react = false,
sourceMaps = false,
Expand Down Expand Up @@ -158,7 +160,7 @@ export function getConfig({
minimizer: [
new TerserPlugin({
sourceMap: sourceMaps,
parallel: true,
parallel: getParallelValue(parallel),
}),
],
},
Expand Down
1 change: 1 addition & 0 deletions packages/nimbus/src/configs/webpack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const { srcFolder, react } = getSettings();

export default getConfig({
analyzeBundle: !!process.env.WEBPACK_ANALYZE,
parallel: process.env.WEBPACK_PARALLEL,
port: process.env.PORT,
react,
sourceMaps: !!process.env.SOURCE_MAPS,
Expand Down
1 change: 1 addition & 0 deletions packages/nimbus/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ export default function nimbus(tool: Beemo) {
env: {
SOURCE_MAPS: context.args.sourceMaps ? 'true' : '',
WEBPACK_ANALYZE: context.args.analyze ? 'true' : '',
WEBPACK_PARALLEL: String(context.args.parallel || ''),
},
});
}, 'webpack');
Expand Down

0 comments on commit 8120201

Please sign in to comment.