Skip to content

Commit

Permalink
fix(webpack): Run builds sequentially (#16)
Browse files Browse the repository at this point in the history
This is designed to avoid overloading the node process if too many builds are being executed at once.
  • Loading branch information
markdalgleish committed Jun 19, 2017
1 parent 7972325 commit e9d58cf
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 13 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"babel-preset-es2015": "^6.22.0",
"babel-preset-react": "^6.22.0",
"babel-preset-react-optimize": "^1.0.1",
"bluebird": "^3.5.0",
"classnames": "^2.2.5",
"cross-spawn": "^5.0.1",
"css-loader": "^0.26.1",
Expand Down
32 changes: 19 additions & 13 deletions scripts/build.js
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!'));

0 comments on commit e9d58cf

Please sign in to comment.