Skip to content

Commit

Permalink
chore: add -w option shorthand to build --watch, improve watch output
Browse files Browse the repository at this point in the history
  • Loading branch information
stafyniaksacha committed Apr 2, 2021
1 parent 43bf3d1 commit 52a7404
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion packages/vite/src/node/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ async function doBuild(

// watch file changes with rollup
if (config.build.watch) {
config.logger.info(chalk.cyanBright(`watching for file changes...`))
config.logger.info(chalk.cyanBright(`\nwatching for file changes...`))

const output: OutputOptions[] = []
if (Array.isArray(outputs)) {
Expand Down Expand Up @@ -469,6 +469,8 @@ async function doBuild(

watcher.on('event', (event) => {
if (event.code === 'BUNDLE_START') {
config.logger.info(chalk.cyanBright(`\nbuild started...`))

// clean previous files
if (options.write) {
emptyDir(outDir)
Expand Down
2 changes: 1 addition & 1 deletion packages/vite/src/node/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ cli
`[boolean] force empty outDir when it's outside of root`
)
.option('-m, --mode <mode>', `[string] set env mode`)
.option('--watch', `[boolean] rebuilds when modules have changed on disk`)
.option('-w, --watch', `[boolean] rebuilds when modules have changed on disk`)
.action(async (root: string, options: BuildOptions & GlobalCLIOptions) => {
const { build } = await import('./build')
const buildOptions = cleanOptions(options) as BuildOptions
Expand Down

0 comments on commit 52a7404

Please sign in to comment.