build.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. // https://github.com/shelljs/shelljs
  2. require('./check-versions')()
  3. require('shelljs/global')
  4. env.NODE_ENV = 'production'
  5. var path = require('path')
  6. var config = require('../config')
  7. var ora = require('ora')
  8. var webpack = require('webpack')
  9. var webpackConfig = require('./webpack.prod.conf')
  10. console.log(
  11. ' Tip:\n' +
  12. ' Built files are meant to be served over an HTTP server.\n' +
  13. ' Opening index.html over file:// won\'t work.\n'
  14. )
  15. var spinner = ora('building for production...')
  16. spinner.start()
  17. var updateEmoji = require('./update-emoji').updateEmoji
  18. updateEmoji()
  19. var assetsPath = path.join(config.build.assetsRoot, config.build.assetsSubDirectory)
  20. rm('-rf', assetsPath)
  21. mkdir('-p', assetsPath)
  22. cp('-R', 'static/*', assetsPath)
  23. webpack(webpackConfig, function (err, stats) {
  24. spinner.stop()
  25. if (err) throw err
  26. process.stdout.write(stats.toString({
  27. colors: true,
  28. modules: false,
  29. children: false,
  30. chunks: false,
  31. chunkModules: false
  32. }) + '\n')
  33. if (stats.hasErrors()) {
  34. console.error('See above for errors.')
  35. process.exit(1)
  36. }
  37. })