#!/usr/bin/env node
const semver = require('semver')
const { error } = require('@vue/cli-shared-utils')
const requiredVersion = require('../package.json').engines.node
if (!semver.satisfies(process.version, requiredVersion)) {
error(
`You are using Node ${process.version}, but vue-cli-service ` +
`requires Node ${requiredVersion}.\nPlease upgrade your Node version.`
)
process.exit(1)
}
const Service = require('../lib/Service')
const service = new Service(process.env.VUE_CLI_CONTEXT || process.cwd()) // 传入当前项目的所在路径 /Users/zyn/WebRoot/Demo/uiit-test
const rawArgv = process.argv.slice(2) // [ 'serve' ] [ 'serve', '--port', '3000' ]
// minimist 命令行参数解析器
const args = require('minimist')(rawArgv, {
boolean: [
// build
'modern',
'report',
'report-json',
'watch',
// serve
'open',
'copy',
'https',
// inspect
'verbose'
]
}) // vue-cli-service serve --port 3000 args 包含 {port: 3000}
const command = args._[0] // serve
service.run(command, args, rawArgv).catch(err => {
error(err)
process.exit(1)
})
vue-cli 3.0 vue-cli-service.js解读
最新推荐文章于 2023-01-08 12:59:35 发布