prod.js 848 B

1234567891011121314151617181920212223242526272829303132
  1. const webpack = require('webpack');
  2. const ora = require('ora');
  3. const rm = require('rimraf');
  4. const chalk = require('chalk');
  5. const config = require('./webpack.config.prod.js');
  6. const spinner = ora('building for production...')
  7. spinner.start();
  8. rm('./www/', (removeErr) => {
  9. if (removeErr) throw removeErr;
  10. webpack(config, (err, stats) => {
  11. if (err) throw err;
  12. spinner.stop();
  13. process.stdout.write(stats.toString({
  14. colors: true,
  15. modules: false,
  16. children: false, // If you are using ts-loader, setting this to true will make TypeScript errors show up during build.
  17. chunks: false,
  18. chunkModules: false
  19. }) + '\n\n');
  20. if (stats.hasErrors()) {
  21. console.log(chalk.red('Build failed with errors.\n'));
  22. process.exit(1);
  23. }
  24. console.log(chalk.cyan('Build complete.\n'));
  25. });
  26. });