build.js 903 B

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