22import minimist from 'minimist' ;
33import path from 'path' ;
44import fs from 'fs-extra' ;
5- import { BuildArgs , build } from 'kkt' ;
5+ import { BuildArgs , build , start } from 'kkt' ;
66import { overridePaths } from 'kkt/lib/overrides/paths' ;
77import { sync as gzipSize } from 'gzip-size' ;
88import filesize from 'filesize' ;
@@ -11,7 +11,7 @@ import { filterPlugins, removeLoaders } from './utils';
1111
1212function help ( ) {
1313 const { version } = require ( '../package.json' ) ;
14- console . log ( '\n Usage: \x1b[34;1mncc\x1b[0m [build] [input-file] [--help|h]' ) ;
14+ console . log ( '\n Usage: \x1b[34;1mncc\x1b[0m [build|watch ] [input-file] [--help|h]' ) ;
1515 console . log ( '\n Displays help information.' ) ;
1616 console . log ( '\n Options:\n' ) ;
1717 console . log ( ' --version, -v ' , 'Show version number' ) ;
@@ -32,6 +32,7 @@ function help() {
3232 console . log ( ' $ \x1b[35mncc\x1b[0m build' ) ;
3333 console . log ( ' $ \x1b[35mncc\x1b[0m build --out ./dist' ) ;
3434 console . log ( ' $ \x1b[35mncc\x1b[0m build --minify' ) ;
35+ console . log ( ' $ \x1b[35mncc\x1b[0m watch --minify' ) ;
3536 console . log ( ' $ \x1b[35mncc\x1b[0m build src/app.ts' ) ;
3637 console . log ( ` $ \x1b[35mncc\x1b[0m build --target web --library MyLibrary` ) ;
3738 console . log ( ` $ \x1b[35mncc\x1b[0m build --source-map` ) ;
@@ -125,6 +126,7 @@ process.on('exit', (code) => {
125126
126127 argvs . out = argvs . o = path . resolve ( argvs . out || argvs . o || 'dist' ) ;
127128 argvs . minify = argvs . m = argvs . minify || argvs . m || false ;
129+ // argvs.watch = argvs.w = argvs.watch || argvs.w || false;
128130
129131 const scriptName = argvs . _ [ 0 ] ;
130132 const inputFile = path . resolve ( argvs . _ [ 1 ] || 'src/index.ts' ) ;
@@ -189,15 +191,23 @@ process.on('exit', (code) => {
189191 }
190192 return conf ;
191193 } ;
194+ data . minify = argvs . minify ;
192195 if ( scriptName === 'build' ) {
193196 await build ( {
194197 ...argvs ,
195198 bundle : true ,
196199 isNotCheckHTML : true ,
197200 overridePaths : { ...oPaths } ,
198201 } ) ;
202+ } else if ( scriptName === 'watch' ) {
203+ await start ( {
204+ ...argvs ,
205+ watch : true ,
206+ bundle : true ,
207+ isNotCheckHTML : true ,
208+ overridePaths : { ...oPaths } ,
209+ } ) ;
199210 }
200- data . minify = argvs . minify ;
201211 } catch ( error ) {
202212 console . log ( '\x1b[31m KKT:NCC:ERROR:\x1b[0m' , error ) ;
203213 }
0 commit comments