Skip to content

Commit

Permalink
feat(build): add 'watch' option (#1332)
Browse files Browse the repository at this point in the history
  • Loading branch information
zigomir authored and yyx990803 committed May 21, 2018
1 parent 3a913a9 commit 6ea17c9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/cli-service.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ Options:
--dest specify output directory (default: dist)
--target app | lib | wc | wc-async (default: app)
--name name for lib or web-component mode (default: "name" in package.json or entry filename)
--watch watch for changes
```

`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.
Expand Down
9 changes: 7 additions & 2 deletions packages/@vue/cli-service/lib/commands/build/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ module.exports = (api, options) => {
'--mode': `specify env mode (default: production)`,
'--dest': `specify output directory (default: ${options.outputDir})`,
'--target': `app | lib | wc | wc-async (default: ${defaults.target})`,
'--name': `name for lib or web-component mode (default: "name" in package.json or entry filename)`
'--name': `name for lib or web-component mode (default: "name" in package.json or entry filename)`,
'--watch': `watch for changes`
}
}, async function build (args) {
args.entry = args.entry || args._[0]
Expand Down Expand Up @@ -100,8 +101,12 @@ module.exports = (api, options) => {
: webpackConfig
).output.path

if (args.watch) {
webpackConfig.watch = true
}

if (!args.dest && actualTargetDir !== api.resolve(options.outputDir)) {
// user directly modifys output.path in configureWebpack or chainWebpack.
// user directly modifies output.path in configureWebpack or chainWebpack.
// this is not supported because there's no way for us to give copy
// plugin the correct value this way.
console.error(chalk.red(
Expand Down

0 comments on commit 6ea17c9

Please sign in to comment.