build.js 917 B

123456789101112131415161718192021222324252627282930313233343536
  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 assetsPath = path.join(config.build.assetsRoot, config.build.assetsSubDirectory)
  18. rm('-rf', assetsPath)
  19. mkdir('-p', assetsPath)
  20. cp('-R', 'static/*', assetsPath)
  21. webpack(webpackConfig, function (err, stats) {
  22. spinner.stop()
  23. if (err) throw err
  24. process.stdout.write(stats.toString({
  25. colors: true,
  26. modules: false,
  27. children: false,
  28. chunks: false,
  29. chunkModules: false
  30. }) + '\n')
  31. })