support inspect paths

This commit is contained in:
Evan You
2018-01-04 11:18:36 -05:00
parent 0f73050bd2
commit 28986a46dc
2 changed files with 9 additions and 5 deletions

View File

@@ -1,23 +1,26 @@
module.exports = (api, options) => {
api.registerCommand('inspect', {
description: 'inspect internal webpack config',
usage: 'vue-cli-service inspect [options] [...keys]',
usage: 'vue-cli-service inspect [options] [...paths]',
options: {
'--mode': 'specify env mode (default: development)'
}
}, args => {
api.setMode(args.mode || 'development')
const get = require('get-value')
const stringify = require('javascript-stringify')
const config = api.resolveWebpackConfig()
const keys = args._
const paths = args._
let res
if (keys.length) {
if (paths.length > 1) {
res = {}
keys.forEach(key => {
res[key] = config[key]
paths.forEach(path => {
res[path] = get(config, path)
})
} else if (paths.length === 1) {
res = get(config, paths[0])
} else {
res = config
}

View File

@@ -37,6 +37,7 @@
"extract-text-webpack-plugin": "^3.0.2",
"file-loader": "^1.1.6",
"friendly-errors-webpack-plugin": "^1.6.1",
"get-value": "^2.0.6",
"html-webpack-plugin": "^2.30.1",
"husky": "^0.14.3",
"javascript-stringify": "^1.6.0",