build.test.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. require('./check-versions')()
  2. process.env.NODE_ENV = 'production'
  3. var ora = require('ora')
  4. var rm = require('rimraf')
  5. var path = require('path')
  6. var chalk = require('chalk')
  7. var webpack = require('webpack')
  8. var config = require('../config')
  9. var webpackConfig = require('./webpack.prod.test.conf')
  10. var argv = process.argv.slice(2);
  11. var isPreProduction = argv.indexOf('preProduction') !== -1;
  12. var spinner = ora('building for production.test...,打包后的静态资源在 eta_front 文件夹中')
  13. spinner.start()
  14. rm(path.join(config.test.assetsRoot, config.test.assetsSubDirectory), err => {
  15. if (err) throw err
  16. webpack(webpackConfig, function (err, stats) {
  17. spinner.stop()
  18. if (err) throw err
  19. process.stdout.write(stats.toString({
  20. colors: true,
  21. modules: false,
  22. children: false,
  23. chunks: false,
  24. chunkModules: false
  25. }) + '\n\n')
  26. console.log(chalk.cyan(' test complete.\n'))
  27. console.log(chalk.yellow(
  28. ' Tip: built files are meant to be served over an HTTP server.\n' +
  29. ' Opening index.html over file:// won\'t work.\n'
  30. ))
  31. })
  32. })