From e791907d1f17297e9a12304a8b98548f24d6480d Mon Sep 17 00:00:00 2001 From: nikek Date: Wed, 1 Apr 2020 11:32:56 +0200 Subject: [PATCH] WIP watch mode --- packages/cli/src/commands/plugin/build.ts | 26 +++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/packages/cli/src/commands/plugin/build.ts b/packages/cli/src/commands/plugin/build.ts index 1cbfd72413..6e5372247d 100644 --- a/packages/cli/src/commands/plugin/build.ts +++ b/packages/cli/src/commands/plugin/build.ts @@ -16,15 +16,33 @@ const rollup = require('rollup'); // "import" is not working for some reason... import rollupConfig from './rollup.config'; +import { Command } from 'commander'; +import { run } from '../../helpers/run'; -export default async () => { +export default async (cmd: Command) => { const inputOptions = { input: rollupConfig.input, plugins: rollupConfig.plugins, }; const outputOptions = rollupConfig.output; - const bundle = await rollup.rollup(inputOptions); - await bundle.generate(outputOptions); - await bundle.write(outputOptions); + if (cmd.watch) { + await run('rollup -c -w'); + // const watchOptions = { + // ...inputOptions, + // output: [outputOptions], + // watch: { + // include: ['src/**/*'], + // chokidar: true, + // }, + // }; + // const watcher = rollup.watch(watchOptions); + // watcher.on('event', (event: any) => { + // process.stdout.write(event); + // }); + } else { + const bundle = await rollup.rollup(inputOptions); + await bundle.generate(outputOptions); + await bundle.write(outputOptions); + } };