mirror of
https://github.com/vuejs/vue-cli.git
synced 2026-04-22 04:18:33 -05:00
feat(inspect): add --rule and --plugin options for inspect command
This commit is contained in:
@@ -83,6 +83,8 @@ module.exports = (api, options) => {
|
||||
usage: 'vue-cli-service inspect [options] [...paths]',
|
||||
options: {
|
||||
'--mode': 'specify env mode (default: development)',
|
||||
'--rule': 'inspect a specific module rule',
|
||||
'--plugin': 'inspect a specific plugin',
|
||||
'--verbose': 'show full function definitions in output'
|
||||
}
|
||||
}, args => {
|
||||
@@ -94,7 +96,11 @@ module.exports = (api, options) => {
|
||||
const paths = args._
|
||||
|
||||
let res
|
||||
if (paths.length > 1) {
|
||||
if (args.rule) {
|
||||
res = config.module.rules.find(r => r.__ruleName === args.rule)
|
||||
} else if (args.plugin) {
|
||||
res = config.plugins.find(p => p.__pluginName === args.plugin)
|
||||
} else if (paths.length > 1) {
|
||||
res = {}
|
||||
paths.forEach(path => {
|
||||
res[path] = get(config, path)
|
||||
@@ -106,7 +112,7 @@ module.exports = (api, options) => {
|
||||
}
|
||||
|
||||
const pluginRE = /(?:function|class) (\w+Plugin)/
|
||||
console.log(stringify(res, (value, indent, stringify) => {
|
||||
const output = stringify(res, (value, indent, stringify) => {
|
||||
// shorten long functions
|
||||
if (
|
||||
!args.verbose &&
|
||||
@@ -151,7 +157,9 @@ module.exports = (api, options) => {
|
||||
}
|
||||
|
||||
return stringify(value)
|
||||
}, 2))
|
||||
}, 2)
|
||||
|
||||
console.log(output)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -68,6 +68,8 @@ program
|
||||
program
|
||||
.command('inspect [paths...]')
|
||||
.option('--mode <mode>')
|
||||
.option('--rule <ruleName>', 'inspect a specific module rule')
|
||||
.option('--plugin <pluginName>', 'inspect a specific plugin')
|
||||
.option('-v --verbose', 'Show full function definitions in output')
|
||||
.description('inspect the webpack config in a project with vue-cli-service')
|
||||
.action((paths, cmd) => {
|
||||
|
||||
@@ -19,6 +19,8 @@ module.exports = function inspect (paths, args) {
|
||||
binPath,
|
||||
'inspect',
|
||||
...(args.mode ? ['--mode', args.mode] : []),
|
||||
...(args.rule ? ['--rule', args.rule] : []),
|
||||
...(args.plugin ? ['--plugin', args.plugin] : []),
|
||||
...(args.verbose ? ['--verbose'] : []),
|
||||
...paths
|
||||
], { cwd, stdio: 'inherit' })
|
||||
|
||||
Reference in New Issue
Block a user