forked from ktsn/vue-cli-plugin-auto-routing
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
51 lines (45 loc) · 1.07 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
const VueAutoRoutingPlugin = require('vue-auto-routing/lib/webpack-plugin');
const chalk = require('chalk');
module.exports = api => {
api.chainWebpack(webpackConfig => {
// prettier-ignore
webpackConfig
.plugin('vue-auto-routing')
.use(VueAutoRoutingPlugin, [
{
pages: 'src/pages',
nested: true
}
])
});
const OPTIONS = {
'--name': 'specifies a name for greeting'
};
api.registerCommand(
'greet',
{
description: 'Writes a greeting to the console',
usage: 'vue-cli-service greet [options]',
options: OPTIONS
},
args => {
if (args.name) {
console.log(`👋 Hello, ${args.name}!`);
} else {
console.log(`👋 Hello!`);
}
}
);
const { serve } = api.service.commands;
const serveFn = serve.fn;
serve.fn = (...args) => {
return serveFn(...args).then(res => {
if (res && res.url) {
console.log(
chalk.green(`Project is running now at`),
chalk.blue(res.url)
);
}
});
};
};