Skip to content

Commit ec144e5

Browse files
committed
Define gulp tasks for minifying and combining JS and CSS source files.
1 parent 2d532aa commit ec144e5

File tree

1 file changed

+43
-8
lines changed

1 file changed

+43
-8
lines changed

src/AngularGettingStarted/gulpfile.js

Lines changed: 43 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,45 @@
1-
/*
2-
This file in the main entry point for defining Gulp tasks and using Gulp plugins.
3-
Click here to learn more. http://go.microsoft.com/fwlink/?LinkId=518007
4-
*/
1+
/// <binding Clean='clean' />
52

6-
var gulp = require('gulp');
3+
var gulp = require("gulp"),
4+
rimraf = require("rimraf"),
5+
concat = require("gulp-concat"),
6+
cssmin = require("gulp-cssmin"),
7+
uglify = require("gulp-uglify"),
8+
project = require("./project.json");
79

8-
gulp.task('default', function () {
9-
// place code for your default task here
10-
});
10+
var paths = {
11+
webroot: "./" + project.webroot + "/"
12+
};
13+
14+
paths.js = paths.webroot + "js/**/*.js";
15+
paths.minJs = paths.webroot + "js/**/*.min.js";
16+
paths.css = paths.webroot + "css/**/*.css";
17+
paths.minCss = paths.webroot + "css/**/*.min.css";
18+
paths.concatJsDest = paths.webroot + "js/site.min.js";
19+
paths.concatCssDest = paths.webroot + "css/site.min.css";
20+
21+
gulp.task("clean:js", function (cb) {
22+
rimraf(paths.concatJsDest, cb);
23+
});
24+
25+
gulp.task("clean:css", function (cb) {
26+
rimraf(paths.concatCssDest, cb);
27+
});
28+
29+
gulp.task("clean", ["clean:js", "clean:css"]);
30+
31+
gulp.task("min:js", function () {
32+
gulp.src([paths.js, "!" + paths.minJs], { base: "." })
33+
.pipe(concat(paths.concatJsDest))
34+
.pipe(uglify())
35+
.pipe(gulp.dest("."));
36+
});
37+
38+
gulp.task("min:css", function () {
39+
gulp.src([paths.css, "!" + paths.minCss])
40+
.pipe(concat(paths.concatCssDest))
41+
.pipe(cssmin())
42+
.pipe(gulp.dest("."));
43+
});
44+
45+
gulp.task("min", ["min:js", "min:css"]);

0 commit comments

Comments
 (0)