-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(webpack): Run builds sequentially (#16)
This is designed to avoid overloading the node process if too many builds are being executed at once.
- Loading branch information
1 parent
7972325
commit e9d58cf
Showing
2 changed files
with
20 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,34 @@ | ||
// First, ensure the build is running in production mode | ||
process.env.NODE_ENV = 'production'; | ||
|
||
const webpack = require('webpack'); | ||
const Promise = require('bluebird'); | ||
const webpackPromise = Promise.promisify(require('webpack')); | ||
const webpackConfig = require('../config/webpack/webpack.config'); | ||
const fs = require('fs-extra'); | ||
const builds = require('../config/builds'); | ||
|
||
webpack(webpackConfig, (err, stats) => { | ||
if (err) { | ||
return console.log(err); | ||
} | ||
|
||
console.log( | ||
stats.toString({ | ||
chunks: false, // Makes the build much quieter | ||
colors: true | ||
}) | ||
); | ||
const runWebpack = config => { | ||
return webpackPromise(config).then(stats => { | ||
console.log( | ||
stats.toString({ | ||
chunks: false, // Makes the build much quieter | ||
colors: true | ||
}) | ||
); | ||
}); | ||
}; | ||
|
||
const copyPublicFiles = () => { | ||
builds.forEach(({ paths }) => { | ||
if (fs.existsSync(paths.public)) { | ||
fs.copySync(paths.public, paths.dist, { | ||
dereference: true | ||
}); | ||
console.log(`Copying ${paths.public} to ${paths.dist}`); | ||
} | ||
}); | ||
}); | ||
}; | ||
|
||
Promise.each(webpackConfig, runWebpack) | ||
.then(copyPublicFiles) | ||
.then(() => console.log('Sku build complete!')); |