GitBucket
4.6.0
Toggle navigation
Sign in
Files
Branches
1
Tags
Issues
Pull Requests
Labels
Milestones
Wiki
08335
/
hivui-platform-template
hivui平台项目模板
Browse code
add
master
1 parent
1ccf909
commit
689ca265dc425c886dd0f99bbe22343097a63283
caibinghong
authored
on 30 Dec 2021
Showing
1 changed file
build/webpack.prod.conf.js
Ignore Space
Show notes
View
build/webpack.prod.conf.js
// 多进程 编译所有 //parallel-webpack允许您并行运行多个Webpack构建,从而将工作分散到各个处理器上,从而有助于显着加快构建速度 let argvs = (process.argv[2] || "").replace(/\s*$/g, "") var run = require('parallel-webpack').run, configPath = require.resolve('./webpack.get-list.js'), options = { watch: false, maxRetries: 1, stats: false, // defaults to false maxConcurrentWorkers: 4,// use 2 workers cup个数 argv: [argvs] }; function notify(res) { //多打包时,如果其中一个模块出错,不知道是哪个模块 console.log('\n--------编译完成------- \n'); } let moduleList = argvs!=""?argvs.split(','):[]; let len = moduleList.length; if (len == 0) { moduleList = require('./webpack.get-module').moduleList || []; console.log('=========进入全模块编译状态...=============') console.log('=========共有'+moduleList.length+'模块=============') run(configPath, options, notify); } else { let webpack = require('webpack') let webpackList = require('./webpack.get-list.js'); console.log('=========指定模块编译状态...==============') console.log('=========共有'+len+'模块=============') webpack(webpackList[0], (err, stats) => { //这个回调一定要写,不然打包不出来 if (err || stats.hasErrors()) {//编译错误不在 err 对象内,而是需要使用 stats.hasErrors() 单独处理 const info = stats.toJson(); // console.error(info.errors); for (let i = 0, l = info.errors.length; i < l; i++) { // console.log(chalk.red(info.errors[i].message)); // console.error(info.errors[i].message) console.error(info.errors[i]) } } // 处理完成 }) }
// 多进程 编译所有 //parallel-webpack允许您并行运行多个Webpack构建,从而将工作分散到各个处理器上,从而有助于显着加快构建速度 let argvs = (process.argv[2] || "").replace(/\s*$/g, "") var run = require('parallel-webpack').run, configPath = require.resolve('./webpack.get-list.js'), options = { watch: false, maxRetries: 1, stats: false, // defaults to false maxConcurrentWorkers: 2,// use 2 workers cup个数 argv: [argvs] }; function notify(res) { //多打包时,如果其中一个模块出错,不知道是哪个模块 console.log('\n--------编译完成------- \n'); } let moduleList = argvs!=""?argvs.split(','):[]; let len = moduleList.length; if (len == 0) { moduleList = require('./webpack.get-module').moduleList || []; console.log('=========进入全模块编译状态...=============') console.log('=========共有'+moduleList.length+'模块=============') run(configPath, options, notify); } else { let webpack = require('webpack') let webpackList = require('./webpack.get-list.js'); console.log('=========指定模块编译状态...==============') console.log('=========共有'+len+'模块=============') webpack(webpackList[0], (err, stats) => { //这个回调一定要写,不然打包不出来 if (err || stats.hasErrors()) {//编译错误不在 err 对象内,而是需要使用 stats.hasErrors() 单独处理 const info = stats.toJson(); // console.error(info.errors); for (let i = 0, l = info.errors.length; i < l; i++) { // console.log(chalk.red(info.errors[i].message)); // console.error(info.errors[i].message) console.error(info.errors[i]) } } // 处理完成 }) }
Show line notes below