run-compiler.js 494 B

12345678910111213141516171819202122
  1. const path = require('path')
  2. const webpack = require('webpack')
  3. const configPath = process.argv[2]
  4. const outPath = path.resolve(process.argv[3])
  5. const config = require(configPath)
  6. config.output = {
  7. path: path.dirname(outPath),
  8. filename: path.basename(outPath)
  9. }
  10. webpack(config, (err, stats) => {
  11. if (err) {
  12. console.error(err)
  13. process.exit(1)
  14. } else if (stats.hasErrors()) {
  15. console.error(stats.toString('normal'))
  16. process.exit(1)
  17. } else {
  18. process.exit(0)
  19. }
  20. })