1 | exports.name = 'builtin:watch'
|
2 |
|
3 | exports.apply = api => {
|
4 | api.hook('createCLI', ({ command, args }) => {
|
5 | command.option('-w, --watch', 'Watch and rebuild on file changes')
|
6 |
|
7 | if (!args.has('w') && !args.has('watch')) return
|
8 |
|
9 | command.action(() => {
|
10 | const compiler = api.createWebpackCompiler(
|
11 | api.createWebpackChain().toConfig()
|
12 | )
|
13 | compiler.watch({}, err => {
|
14 | if (err) {
|
15 | api.logger.error(err)
|
16 | }
|
17 | })
|
18 | })
|
19 | })
|
20 | }
|