Skip to content

Commit

Permalink
chore(dll): fix dll build order (#563)
Browse files Browse the repository at this point in the history
  • Loading branch information
levithomason authored Sep 28, 2016
1 parent 788e5d5 commit 25fd1e7
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 34 deletions.
56 changes: 56 additions & 0 deletions gulp/tasks/dll.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import del from 'del'
import { task, series } from 'gulp'
import loadPlugins from 'gulp-load-plugins'
import webpack from 'webpack'

import config from '../../config'

const g = loadPlugins()
const { log, PluginError } = g.util

// ----------------------------------------
// Clean
// ----------------------------------------

task('clean:dll', (cb) => {
del.sync(config.paths.base('dll'))
cb()
})

// ----------------------------------------
// Build
// ----------------------------------------

task('build:dll', (cb) => {
const webpackDLLConfig = require('../../webpack.dll')
const compiler = webpack(webpackDLLConfig)

compiler.run((err, stats) => {
const { errors, warnings } = stats.toJson()

log(stats.toString(config.compiler_stats))

if (err) {
log('Webpack compiler encountered a fatal error.')
throw new PluginError('webpack', err.toString())
}
if (errors.length > 0) {
log('Webpack compiler encountered errors.')
throw new PluginError('webpack', errors.toString())
}
if (warnings.length > 0 && config.compiler_fail_on_warning) {
throw new PluginError('webpack', warnings.toString())
}

cb(err)
})
})

// ----------------------------------------
// Default
// ----------------------------------------

task('dll', series(
'clean:dll',
'build:dll',
))
39 changes: 9 additions & 30 deletions gulp/tasks/docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,31 +48,6 @@ task('build:docs:docgen', () => {
.pipe(dest(config.paths.docsSrc()))
})

task('build:docs:dll', (cb) => {
const webpackDLLConfig = require('../../webpack.dll')
const compiler = webpack(webpackDLLConfig)

compiler.run((err, stats) => {
const { errors, warnings } = stats.toJson()

log(stats.toString(config.compiler_stats))

if (err) {
log('Webpack compiler encountered a fatal error.')
throw new PluginError('webpack', err.toString())
}
if (errors.length > 0) {
log('Webpack compiler encountered errors.')
throw new PluginError('webpack', errors.toString())
}
if (warnings.length > 0 && config.compiler_fail_on_warning) {
throw new PluginError('webpack', warnings.toString())
}

cb(err)
})
})

task('build:docs:html', () => {
return src(config.paths.docsSrc('404.html'))
.pipe(dest(config.paths.docsDist()))
Expand Down Expand Up @@ -110,10 +85,15 @@ task('build:docs:webpack', (cb) => {

task('build:docs', series(
parallel(
'build:docs:docgen',
'build:docs:dll',
'build:docs:html',
'build:docs:images'
'dll',
series(
'clean:docs',
parallel(
'build:docs:docgen',
'build:docs:html',
'build:docs:images'
)
)
),
'build:docs:webpack',
))
Expand Down Expand Up @@ -172,7 +152,6 @@ task('watch:docs', (cb) => {
// ----------------------------------------

task('docs', series(
'clean:docs',
'build:docs',
'serve:docs'
))
10 changes: 8 additions & 2 deletions gulp/tasks/umd.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import del from 'del'
import { task, series } from 'gulp'
import { task, parallel, series } from 'gulp'
import loadPlugins from 'gulp-load-plugins'
import webpack from 'webpack'

Expand Down Expand Up @@ -47,11 +47,17 @@ task('build:umd:webpack', (cb) => {
})

task('build:umd', series(
parallel(
'dll',
'clean:umd'
),
'build:umd:webpack'
))

// ----------------------------------------
// Default
// ----------------------------------------

task('umd', series('clean:umd', 'build:umd'))
task('umd', series(
'build:umd'
))
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@
"scripts": {
"docs": "gulp docs",
"build": "npm run build:commonjs && npm run build:umd && npm run build:docs",
"prebuild:commonjs": "rimraf dist/commonjs",
"prebuild:commonjs": "rimraf dist/commonjs && npm run build:dll",
"build:commonjs": "babel src -d dist/commonjs",
"prebuild:docs": "npm run build:docs-toc",
"build:dll": "gulp dll",
"build:docs": "gulp build:docs",
"build:umd": "cross-env NODE_ENV=browser gulp umd",
"build:docs-toc": "doctoc README.md ./.github/CONTRIBUTING.md --github --maxlevel 4",
Expand All @@ -30,7 +31,7 @@
"release:patch": "ta-script npm/release.sh patch",
"start": "npm run docs",
"start:local-modules": "npm run docs -- --local-modules",
"pretest": "gulp build:docs:dll",
"pretest": "npm run build:dll",
"test": "cross-env NODE_ENV=test karma start",
"test:watch": "npm run test --silent -- --watch"
},
Expand Down

0 comments on commit 25fd1e7

Please sign in to comment.