Skip to content

Commit 4c00cfa

Browse files
committed
feat: vue inspect that proxies to vue-cli-service
1 parent fd87394 commit 4c00cfa

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

packages/@vue/cli/bin/vue.js

+8
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,14 @@ program
5454
require('../lib/invoke')(plugin, minimist(process.argv.slice(3)))
5555
})
5656

57+
program
58+
.command('inspect [paths...]')
59+
.option('--mode <mode>')
60+
.description('inspect the webpack config in a project with vue-cli-service')
61+
.action((paths, cmd) => {
62+
require('../lib/inspect')(paths, cmd.mode)
63+
})
64+
5765
program
5866
.command('serve [entry]')
5967
.description('serve a .js or .vue file in development mode with zero config')

packages/@vue/cli/lib/inspect.js

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
const fs = require('fs')
2+
const path = require('path')
3+
const execa = require('execa')
4+
const resolve = require('resolve')
5+
6+
module.exports = function inspect (paths, mode) {
7+
const cwd = process.cwd()
8+
let servicePath
9+
try {
10+
servicePath = resolve.sync('@vue/cli-service', { cwd })
11+
} catch (e) {
12+
const { error } = require('@vue/cli-shared-utils')
13+
error(`Failed to locate @vue/cli-service. Make sure you are in the right directory.`)
14+
process.exit(1)
15+
}
16+
const binPath = path.resolve(servicePath, '../../bin/vue-cli-service.js')
17+
if (fs.existsSync(binPath)) {
18+
execa('node', [
19+
binPath,
20+
'inspect',
21+
...(mode ? ['--mode', mode] : []),
22+
...paths
23+
], { cwd, stdio: 'inherit' })
24+
}
25+
}

0 commit comments

Comments
 (0)