Skip to content

feat(build): add 'watch' option #1332

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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