Vue – build -build.js文件解析


‘use strict’
require(’./check-versions’)()// 检查NodeJS和npm的版本

process.env.NODE_ENV = ‘production’
const ora = require(‘ora’)
const rm = require(‘rimraf’)
const path = require(‘path’)
// 高亮控制台输出的插件
const chalk = require(‘chalk’)
const webpack = require(‘webpack’)
const config = require(’…/config’)
const webpackConfig = require(’./’)
//在控制台输出building for production…
const spinner = ora(‘building for production…’)
rm(path.join(,, err => {
if (err) throw err
webpack(webpackConfig, (err, stats) => {
if (err) throw err
colors: true,
modules: false,
children: false, // If you are using ts-loader, setting this to true will make TypeScript errors show up during build.
chunks: false,
chunkModules: false
}) + ‘\n\n’)

if (stats.hasErrors()) {
  console.log('  Build failed with errors.\n'))

console.log(chalk.cyan('  Build complete.\n'))
  '  Tip: built files are meant to be served over an HTTP server.\n' +
  '  Opening index.html over file:// won\'t work.\n'


版权声明:本文为Hxp_123456原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。