node_modules > @vue > cli-service > lib > commands > serve.js
//设置服务器host及port
const defaults = {
host: '0.0.0.0',
port: 8080,
https: false
}
//文件输出运行....
module.exports = (api, options) => {
//查看api对象属性,如下码所示
console.log(api)
api.registerCommand('serve', {
......
api对象属性,如下码所示
PluginAPI {
id: 'built-in:commands/serve',
service:
Service {
initialized: true,
context: 'path/works/vue-cli2/hello-world',
inlineOptions: undefined,
webpackChainFns: [],
webpackRawConfigFns: [],
devServerConfigFns: [],
commands: {},
pkgContext: 'path/works/vue-cli2/hello-world',
pkg:
{ name: 'hello-world',
version: '0.1.0',
private: true,
scripts: [Object],
dependencies: [Object],
devDependencies: [Object],
eslintConfig: [Object],
browserslist: [Array],
readme: 'ERROR: No README data found!',
_id: '[email protected]' },
plugins:
[ [Object],
[Object],
[Object],
[Object],
[Object],
[Object],
[Object],
[Object],
[Object],
[Object] ],
pluginsToSkip: Set {},
modes:
{ serve: 'development',
build: 'production',
inspect: 'development' },
mode: 'development',
projectOptions:
{ publicPath: '/',
outputDir: 'dist',
assetsDir: '',
indexPath: 'index.html',
filenameHashing: true,
runtimeCompiler: false,
transpileDependencies: [],
productionSourceMap: true,
parallel: true,
pages: undefined,
crossorigin: undefined,
integrity: false,
css: {},
lintOnSave: 'default',
devServer: {} } } }
在上面的api对象中我们可以看到,各命令对应的mode,即process.env.NODE_ENV
modes:
{ serve: 'development',
build: 'production',
inspect: 'development' }
上面的api对应的属性projectOptions可在 node_modules > @vue > cli-service > lib> options.js 文件中查看到
exports.defaults = () => ({
// project deployment base
publicPath: '/',
// where to output built files
outputDir: 'dist',
// where to put static assets (js/css/img/font/...)
assetsDir: '',
// filename for index.html (relative to outputDir)
indexPath: 'index.html',
// whether filename will contain hash part
filenameHashing: true,
// boolean, use full build?
runtimeCompiler: false,
// deps to transpile
transpileDependencies: [
/* string or regex */
],
// sourceMap for production build?
productionSourceMap: !process.env.VUE_CLI_TEST,
// use thread-loader for babel & TS in production build
// enabled by default if the machine has more than 1 cores
parallel: hasMultipleCores(),
// multi-page config
pages: undefined,
//