Due to the needs of the project, the rouer is divided into many files, resulting in webpack packaging and compilation is very slow, how to improve the packaging and compilation speed?



let appid = process.env.appid
let isFFZ = process.env.appid = = "ffz"
let isLOTTERY = process.env.appid = =" lottery"
let isCLUB = process.env.appid = = "club"
let isFFZF = process.env.appid = =" ffzf"
let isPOCKET = process.env.appid = = "pocket"
let isTOOL = process.env.appid = =" tool"

export {
isiOS,
isInWx,
isCLUB,
isFFZ,
isFFZF,
isLOTTERY,
isPOCKET,
isTOOL
}


//
let router
if (isFFZ){
  router = require("@/router/ffzindex").default
}
else if (isCLUB){
  router = require("@/router/clubindex").default
}
else if(isLOTTERY){
  router = require("@/router/index").default
}
else if(isFFZF){
  router = require("@/router/ffzfindex").default
}
else if(isPOCKET){
  router = require("@/router/pocketindex").default
}
else if(isTOOL){
  router = require("@/router/toolrouter").default
}

as shown in the picture, it leads to repeated packaging, and it is useless to judge the introduction! Ask all of you for advice

Nov.26,2021

isFFZ you these variables become, need to be put in the browser to calculate a value, of course, all have to be packaged


actually, take a look at your isFFZ similar variables are defined, should take the current node runtime environment definition of variables, such as process.env.IS_FFZ . It can be defined with cross-env . Refer to this article, portal . Here is an example that you can also refer to, Portal

Menu