github.com/titpetric/pendulum@v0.1.180207-1512.0.20180514135826-1f399445df57/front/src/build/build.js (about)

     1  require('./check-versions')()
     2  
     3  process.env.NODE_ENV = 'production'
     4  
     5  var fs = require('fs')
     6  var ora = require('ora')
     7  var rm = require('rimraf')
     8  var path = require('path')
     9  var chalk = require('chalk')
    10  var webpack = require('webpack')
    11  var config = require('../config')
    12  var webpackConfig = require('./webpack.prod.conf')
    13  
    14  var 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, function (err, stats) {
    20      spinner.stop()
    21      if (err) throw err
    22      fs.writeFileSync('./stats.json', JSON.stringify(stats.toJson()))
    23      process.stdout.write(stats.toString({
    24        colors: true,
    25        modules: false,
    26        children: false,
    27        chunks: false,
    28        chunkModules: false
    29      }) + '\n\n')
    30  
    31      console.log(chalk.cyan('  Build complete.\n'))
    32      console.log(chalk.yellow(
    33        '  Tip: built files are meant to be served over an HTTP server.\n' +
    34        '  Opening index.html over file:// won\'t work.\n'
    35      ))
    36    })
    37  })