| 1 |
require('./check-versions')() |
| 2 |
|
| 3 |
process.env.NODE_ENV = 'production' |
| 4 |
|
| 5 |
var ora = require('ora') |
| 6 |
var rm = require('rimraf') |
| 7 |
var path = require('path') |
| 8 |
var chalk = require('chalk') |
| 9 |
var webpack = require('webpack') |
| 10 |
var config = require('../config') |
| 11 |
var webpackConfig = require('./webpack.prod.conf') |
| 12 |
|
| 13 |
var spinner = ora('building for production...') |
| 14 |
spinner.start() |
| 15 |
|
| 16 |
rm(path.join(config.build.assetsRoot, config.build.assetsSubDirectory), err => { |
| 17 |
if (err) throw err |
| 18 |
webpack(webpackConfig, function (err, stats) { |
| 19 |
spinner.stop() |
| 20 |
if (err) throw err |
| 21 |
process.stdout.write(stats.toString({ |
| 22 |
colors: true, |
| 23 |
modules: false, |
| 24 |
children: false, |
| 25 |
chunks: false, |
| 26 |
chunkModules: false |
| 27 |
}) + '\n\n') |
| 28 |
|
| 29 |
if (stats.hasErrors()) { |
| 30 |
console.log(chalk.red(' Build failed with errors.\n')) |
| 31 |
process.exit(1) |
| 32 |
} |
| 33 |
|
| 34 |
console.log(chalk.cyan(' Build complete.\n')) |
| 35 |
console.log(chalk.yellow( |
| 36 |
' Tip: built files are meant to be served over an HTTP server.\n' + |
| 37 |
' Opening index.html over file:// won\'t work.\n' |
| 38 |
)) |
| 39 |
}) |
| 40 |
}) |
| 41 |
|