Skip to content

Commit 6ea17c9

Browse files
zigomiryyx990803
authored andcommitted
feat(build): add 'watch' option (#1332)
1 parent 3a913a9 commit 6ea17c9

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

docs/cli-service.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ Options:
104104
--dest specify output directory (default: dist)
105105
--target app | lib | wc | wc-async (default: app)
106106
--name name for lib or web-component mode (default: "name" in package.json or entry filename)
107+
--watch watch for changes
107108
```
108109

109110
`vue-cli-service build` produces a production-ready bundle in the `dist/` directory, with minification for JS/CSS/HTML and auto vendor chunk splitting for better caching. The chunk manifest is inlined into the HTML.

packages/@vue/cli-service/lib/commands/build/index.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ module.exports = (api, options) => {
1717
'--mode': `specify env mode (default: production)`,
1818
'--dest': `specify output directory (default: ${options.outputDir})`,
1919
'--target': `app | lib | wc | wc-async (default: ${defaults.target})`,
20-
'--name': `name for lib or web-component mode (default: "name" in package.json or entry filename)`
20+
'--name': `name for lib or web-component mode (default: "name" in package.json or entry filename)`,
21+
'--watch': `watch for changes`
2122
}
2223
}, async function build (args) {
2324
args.entry = args.entry || args._[0]
@@ -100,8 +101,12 @@ module.exports = (api, options) => {
100101
: webpackConfig
101102
).output.path
102103

104+
if (args.watch) {
105+
webpackConfig.watch = true
106+
}
107+
103108
if (!args.dest && actualTargetDir !== api.resolve(options.outputDir)) {
104-
// user directly modifys output.path in configureWebpack or chainWebpack.
109+
// user directly modifies output.path in configureWebpack or chainWebpack.
105110
// this is not supported because there's no way for us to give copy
106111
// plugin the correct value this way.
107112
console.error(chalk.red(

0 commit comments

Comments
 (0)