Skip to content

Commit 86dfdab

Browse files
committed
- replacing the rimraf call inside the script in package.json through a gulp cleanup task that calls rimraf to delete both the tmp and dist folders
- adding a few comments to the gulp file - adding a prepublish step to the package.json file to call npm run build before publishing
1 parent 6ef53c8 commit 86dfdab

File tree

2 files changed

+28
-4
lines changed

2 files changed

+28
-4
lines changed

gulpfile.babel.js

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import ngc from 'gulp-ngc';
33
import less from 'gulp-less';
44
import inline from 'gulp-inline-ng2-template';
55

6+
import rimraf from 'rimraf';
7+
68
import fs from 'fs';
79

810
function lessProcessor(path, ext, file, cb) {
@@ -13,17 +15,34 @@ function lessProcessor(path, ext, file, cb) {
1315
}
1416
}
1517

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'], () => {
1730
return gulp.src(["src/**/*"])
1831
.pipe(gulp.dest('tmp'));
1932
});
2033

21-
gulp.task('less', () => {
34+
/**
35+
* compile all less files to css files in the tmp folder
36+
*/
37+
gulp.task('less', ['cleanup'], () => {
2238
return gulp.src('./src/**/*.less')
2339
.pipe(less())
2440
.pipe(gulp.dest('tmp'));
2541
});
2642

43+
/**
44+
* inline both the html and stylesheets inside the angular 2 typescript template files inside the tmp folder
45+
*/
2746
gulp.task('inline', ['less', 'move-to-tmp'], () => {
2847
return gulp.src(['tmp/**/*.ts'])
2948
.pipe(inline({
@@ -33,8 +52,12 @@ gulp.task('inline', ['less', 'move-to-tmp'], () => {
3352
.pipe(gulp.dest('tmp'));
3453
});
3554

55+
/**
56+
* compile the typescript files from the tmp folder to javascript files and save the resulting files
57+
* inside the dist folder
58+
*/
3659
gulp.task('compile', ['inline'], () => {
3760
return ngc('tmp/tsconfig.aot.json');
3861
});
3962

40-
gulp.task('default', ['move-to-tmp', 'less', 'compile']);
63+
gulp.task('default', ['cleanup', 'move-to-tmp', 'less', 'inline', 'compile']);

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828
"pretest": "npm run lint",
2929
"test": "karma start",
3030
"test-watch": "karma start --no-single-run --auto-watch",
31-
"build": "rimraf dist && gulp"
31+
"build": "gulp",
32+
"prepublish": "npm run build"
3233
},
3334
"dependencies": {
3435
"@angular/common": "^2.4.7",

0 commit comments

Comments
 (0)