Skip to content

Instantly share code, notes, and snippets.

@Garbee
Created January 20, 2017 20:15
Show Gist options
  • Save Garbee/6568f999f23ee4b6d0a8e8eb5e0427d3 to your computer and use it in GitHub Desktop.
Save Garbee/6568f999f23ee4b6d0a8e8eb5e0427d3 to your computer and use it in GitHub Desktop.
const path = require("path");
const webpack = require('webpack');
function makeBundle({ outputPath, projectPath, watch = false }) {
const webpackConfig = require(path.resolve(projectPath, "webpack.config.js"));
return new Promise((resolve, reject) => {
const webpackCompiler = webpack(webpackConfig);
const postRun = (error, stats) => {
if (stats.hasErrors()) {
reject();
}
resolve();
};
if (watch) {
return webpackCompiler.watch({}, postRun);
}
return webpackCompiler.run(postRun);
});
}
module.exports = makeBundle;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment