Merge "Add test-scheduler dir to verity"
[bottlenecks.git] / test-scheduler / ui / build / build.js
1 'use strict'
2 require('./check-versions')()
3
4 process.env.NODE_ENV = 'production'
5
6 const ora = require('ora')
7 const rm = require('rimraf')
8 const path = require('path')
9 const chalk = require('chalk')
10 const webpack = require('webpack')
11 const config = require('../config')
12 const webpackConfig = require('./webpack.prod.conf')
13
14 const spinner = ora('building for production...')
15 spinner.start()
16
17 rm(path.join(config.build.assetsRoot, config.build.assetsSubDirectory), err => {
18   if (err) throw err
19   webpack(webpackConfig, (err, stats) => {
20     spinner.stop()
21     if (err) throw err
22     process.stdout.write(stats.toString({
23       colors: true,
24       modules: false,
25       children: false, // If you are using ts-loader, setting this to true will make TypeScript errors show up during build.
26       chunks: false,
27       chunkModules: false
28     }) + '\n\n')
29
30     if (stats.hasErrors()) {
31       console.log(chalk.red('  Build failed with errors.\n'))
32       process.exit(1)
33     }
34
35     console.log(chalk.cyan('  Build complete.\n'))
36     console.log(chalk.yellow(
37       '  Tip: built files are meant to be served over an HTTP server.\n' +
38       '  Opening index.html over file:// won\'t work.\n'
39     ))
40   })
41 })