Series of articles Portal:
1, Build/webpack.base.conf.js
2, Build/webpack.prod.conf.js
3, Build/webpack.dev.conf.js
4, Build/utils.js
5, Build/vue-loader.conf.js
6, Build/build.js
7, Build/dev-server.js
8, Build/check-versions.js
9 、.. /config/index.js
The following is a description of the relevant code and configuration in Build/check-versions.js
/** Version Verification Tool **/varChalk = require (' Chalk '))//The following is a semver plug-in that is used to judge a particular version number, such as//semver.gt (' 1.2.3 ', ' 9.8.7 ') false 1.2. Version 3 is lower than 9.8.7 version//semver.satisfies (' 1.2.3 ', ' 1.x | | >=2.5.0 | | 5.0.0-7.2.3 ') True 1.2.3 version conforms to the following rulesvarSemver = require (' Semver '))varPackageconfig = require ('.. /package.json ')varShell = require (' Shelljs ')//scripts can execute Unix system commands by creating new child processes through the Child_process module//The following code is actually the value of the cmd this parameter passed, converted to a string without spaces before and after, that is, the version numberfunctionexec (cmd) {returnRequire (' child_process '). Execsync (cmd). toString (). Trim ()}varVersionrequirements =[{name:' Node ', CurrentVersion:semver.clean (process.version),//Current environment version, using the Semver plugin to transform the current environment version information into a specified format, that is, ' =v1.2.3 ', ' 1.2.3 ' this functionVersionRequirement:packageConfig.engines.node//required version, which is specified in Pakage.json in the engines option of node version information "Node": ">= 4.0.0" },]//in NPM environmentsif(Shell.which (' NPM ')) {versionrequirements.push ({name:' NPM ', Currentversion:exec (' NPM--version '),//Execute method Get version numberversionRequirement:packageConfig.engines.npm//Required Version})}module.exports=function () { varWarnings = [] for(vari = 0; i < versionrequirements.length; i++) { varMoD =Versionrequirements[i]//The above decision is that if the version number does not conform to the version number specified in the Package.json file, execute the following code if(!semver.satisfies (mod.currentversion, mod.versionrequirement)) {Warnings.push (Mod.name+ ': ' +chalk.red (mod.currentversion)+ ' should be ' +Chalk.green (mod.versionrequirement))} } if(warnings.length) {Console.log (‘‘) Console.log (Chalk.yellow (' To the use of this template, you must update following to modules: ') ) Console.log () for(vari = 0; i < warnings.length; i++) { varWarning =Warnings[i] Console.log ("+warning)} Console.log () Process.exit (1) }}
Reference: http://www.cnblogs.com/ye-hcj/archive/2017/06.html
VUE-CLI Scaffolding NPM Related file description (8) check-versions.js