vue-cli中配置webpack系列文章一 ------build.js
build.js
// 设置process.env.NODE_ENV process.env.NODE_ENV = 'production' //引入ora,可以实现loading效果 var ora = require('ora'); //引入webpack模块 var webpack = require('webpack'); //引入path模块 var path = require('path'); // 引入rimraf模块 // "rm -rf"命令 var rm = require('rimraf') //引入pro环境 var webpackConfig = require('./webpack.prod.conf'); //引入公共配置 var config = require('../config/index'); //加载时显示的文本 var spinner = ora('building for production...'); //加载动画开始 spinner.start() var assetsPath = path.join(config.build.assetsRoot,config.build.assetsSubDirectory); // 清空静态资源的二级目录下所有内容 rm(assetsPath,err=>{ if (err) throw err //启动webpack编译生产环境webpack配置 webpack(webpackConfig,function (eror,stats) { //加载动画结束 spinner.stop(); //// 如果出错,抛出错误 if(eror) throw eror // process.stdout标准输出流 // rocess.stdout.write命令行窗口向用户显示内容 // stats.toString(options)返回格式化结果 process.stdout.write(stats.toString({ colors: true, modules: false, children: false, chunks: false, chunkModules: false })+'\n') }) })
相关推荐
hline 2020-07-29
不知道该写啥QAQ 2020-07-18
helloxiaoliang 2020-06-21
webpackvuees 2020-07-23
gloria0 2020-06-09
不知道该写啥QAQ 2020-11-12
webfullStack 2020-11-09
Yvettre 2020-09-15
想做大牛的蜗牛 2020-10-30
gloria0 2020-10-26
gaojie0 2020-09-11
SelinaChan 2020-08-14
不知道该写啥QAQ 2020-08-09
gloria0 2020-08-09
不知道该写啥QAQ 2020-08-02
SelinaChan 2020-07-28
wangdianyong 2020-07-23
yqoxygen 2020-07-20