@@ -3,6 +3,8 @@ import ngc from 'gulp-ngc';
3
3
import less from 'gulp-less' ;
4
4
import inline from 'gulp-inline-ng2-template' ;
5
5
6
+ import rimraf from 'rimraf' ;
7
+
6
8
import fs from 'fs' ;
7
9
8
10
function lessProcessor ( path , ext , file , cb ) {
@@ -13,17 +15,34 @@ function lessProcessor(path, ext, file, cb) {
13
15
}
14
16
}
15
17
16
- gulp . task ( 'move-to-tmp' , ( ) => {
18
+ /**
19
+ * delete the tmp and dist folders
20
+ */
21
+ gulp . task ( 'cleanup' , ( cb ) => {
22
+ rimraf . sync ( 'tmp' ) ;
23
+ rimraf ( 'dist' , cb ) ;
24
+ } ) ;
25
+
26
+ /**
27
+ * move all files from the src folder to the tmp folder
28
+ */
29
+ gulp . task ( 'move-to-tmp' , [ 'cleanup' ] , ( ) => {
17
30
return gulp . src ( [ "src/**/*" ] )
18
31
. pipe ( gulp . dest ( 'tmp' ) ) ;
19
32
} ) ;
20
33
21
- gulp . task ( 'less' , ( ) => {
34
+ /**
35
+ * compile all less files to css files in the tmp folder
36
+ */
37
+ gulp . task ( 'less' , [ 'cleanup' ] , ( ) => {
22
38
return gulp . src ( './src/**/*.less' )
23
39
. pipe ( less ( ) )
24
40
. pipe ( gulp . dest ( 'tmp' ) ) ;
25
41
} ) ;
26
42
43
+ /**
44
+ * inline both the html and stylesheets inside the angular 2 typescript template files inside the tmp folder
45
+ */
27
46
gulp . task ( 'inline' , [ 'less' , 'move-to-tmp' ] , ( ) => {
28
47
return gulp . src ( [ 'tmp/**/*.ts' ] )
29
48
. pipe ( inline ( {
@@ -33,8 +52,12 @@ gulp.task('inline', ['less', 'move-to-tmp'], () => {
33
52
. pipe ( gulp . dest ( 'tmp' ) ) ;
34
53
} ) ;
35
54
55
+ /**
56
+ * compile the typescript files from the tmp folder to javascript files and save the resulting files
57
+ * inside the dist folder
58
+ */
36
59
gulp . task ( 'compile' , [ 'inline' ] , ( ) => {
37
60
return ngc ( 'tmp/tsconfig.aot.json' ) ;
38
61
} ) ;
39
62
40
- gulp . task ( 'default' , [ 'move-to-tmp' , 'less' , 'compile' ] ) ;
63
+ gulp . task ( 'default' , [ 'cleanup' , ' move-to-tmp', 'less' , 'inline ', 'compile' ] ) ;
0 commit comments