@@ -8,10 +8,7 @@ import { getWebpackStatsConfig } from '../models/';
8
8
import { CliConfig } from '../models/config' ;
9
9
10
10
11
- // Configure build and output;
12
- let lastHash : any = null ;
13
-
14
- export default < any > Task . extend ( {
11
+ export default Task . extend ( {
15
12
run : function ( runTaskOptions : BuildOptions ) {
16
13
17
14
const project = this . cliProject ;
@@ -39,31 +36,33 @@ export default <any>Task.extend({
39
36
runTaskOptions . extractCss ,
40
37
) . config ;
41
38
42
- const webpackCompiler : any = webpack ( config ) ;
43
-
39
+ const webpackCompiler = webpack ( config ) ;
44
40
const statsConfig = getWebpackStatsConfig ( runTaskOptions . verbose ) ;
45
41
46
42
return new Promise ( ( resolve , reject ) => {
47
- webpackCompiler . run ( ( err : any , stats : any ) => {
43
+ const callback : webpack . compiler . CompilerCallback = ( err , stats ) => {
48
44
if ( err ) {
49
45
return reject ( err ) ;
50
46
}
51
47
52
- // Don't keep cache
53
- // TODO: Make conditional if using --watch
54
- webpackCompiler . purgeInputFileSystem ( ) ;
48
+ this . ui . writeLine ( stats . toString ( statsConfig ) ) ;
55
49
56
- if ( stats . hash !== lastHash ) {
57
- lastHash = stats . hash ;
58
- process . stdout . write ( stats . toString ( statsConfig ) + '\n' ) ;
50
+ if ( runTaskOptions . watch ) {
51
+ return ;
59
52
}
60
53
61
54
if ( stats . hasErrors ( ) ) {
62
55
reject ( ) ;
63
56
} else {
64
57
resolve ( ) ;
65
58
}
66
- } ) ;
59
+ } ;
60
+
61
+ if ( runTaskOptions . watch ) {
62
+ webpackCompiler . watch ( { } , callback ) ;
63
+ } else {
64
+ webpackCompiler . run ( callback ) ;
65
+ }
67
66
} )
68
67
. catch ( ( err : Error ) => {
69
68
if ( err ) {
0 commit comments