Created
January 20, 2017 20:15
-
-
Save Garbee/6568f999f23ee4b6d0a8e8eb5e0427d3 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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