perf(builder): improve production build

This commit is contained in:
Pooya Parsa 2018-03-23 12:44:58 +04:30
parent f2fa8c8dd8
commit 00ef16d6dd
3 changed files with 14 additions and 9 deletions

View File

@ -15,7 +15,7 @@ import Debug from 'debug'
import Glob from 'glob'
import upath from 'upath'
import { r, wp, wChunk, createRoutes, parallel, relativeTo, waitFor, createSpinner } from '../common/utils'
import { r, wp, wChunk, createRoutes, parallel, sequence, relativeTo, waitFor, createSpinner } from '../common/utils'
import Options from '../common/options'
import PerfLoader from './webpack/utils/perf-loader'
@ -474,7 +474,9 @@ export default class Builder {
}
// Start Builds
await parallel(this.compilers, compiler => {
const runner = this.options.dev ? parallel : sequence
await runner(this.compilers, compiler => {
return this.webpackCompile(compiler)
})
}

View File

@ -44,19 +44,22 @@ export default class ProgressPlugin extends webpack.ProgressPlugin {
const progress = Math.floor(percent * 100)
this.state.progress = progress
this.state.msg = (msg && msg.length) ? msg : (progress === 100 ? 'done' : 'still building')
this.state.msg = msg
this.state.details = details
this.state.isRunning = (progress && progress !== 100) && (msg && msg.length)
// Process all states
let inProgress = false
let isRunning = false
const lines = []
_.sortBy(Object.keys(sharedState), s => s.name).forEach(name => {
const state = sharedState[name]
if (state.progress < 100) {
inProgress = true
if (state.isRunning) {
isRunning = true
} else {
return
}
const _color = chalk.keyword(state.color)
@ -70,7 +73,7 @@ export default class ProgressPlugin extends webpack.ProgressPlugin {
lines.push([_icon, _name, _bar, _msg, _progress].join(' '))
})
if (!inProgress) {
if (!isRunning) {
logUpdate.clear()
} else {
const title = chalk.bgRedBright.black('BUILDING')

View File

@ -38,8 +38,8 @@ export const createSpinner = function ({ minimal = false }) {
// eslint-disable-next-line no-console
const createLogger = (tag, ctx) => (...args) => ctx.enabled && console.log(
`[${(new Date().toISOString)()}]`,
_.padEnd(`[${tag}]`, 10),
_.padEnd(`[${tag.toUpperCase()}]`, 9),
`[${new Date().toLocaleTimeString()}]`,
...args
)