-
Notifications
You must be signed in to change notification settings - Fork 86
/
gulpfile.js
110 lines (98 loc) · 3.16 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/* eslint-env node */
var gulp = require("gulp");
var sass = require("gulp-sass");
var minifyCSS = require("gulp-minify-css");
var htmlmin = require("gulp-htmlmin");
var autoprefixer = require("gulp-autoprefixer");
var runSequence = require("run-sequence");
var connect = require("gulp-connect");
var gfi = require("gulp-file-insert");
var uglify = require("gulp-uglify");
var eslint = require("gulp-eslint");
var size = require("gulp-size");
var replace = require("gulp-replace");
var protractor = require("gulp-protractor").protractor;
var Karma = require("karma").Server;
var rename = require("gulp-rename");
function p(path) {
return __dirname + (path.charAt(0) === "/" ? "" : "/") + path;
}
gulp.task("js", function() {
return gulp
.src(p("src/angular-material-calendar.js"))
.pipe(eslint())
.pipe(eslint.format())
.pipe(gfi({
"/* angular-material-calendar.html */": p("dist/angular-material-calendar.html"),
"/* angular-material-calendar.css */": p("dist/angular-material-calendar.min.css")
}))
.pipe(gulp.dest("dist"))
.pipe(gulp.dest(""))
.pipe(uglify())
.pipe(size({ gzip: true, prettySize: true }))
.pipe(rename({ suffix: ".min" }))
.pipe(gulp.dest("dist"))
.pipe(gulp.dest(""));
});
gulp.task("html", function() {
return gulp
.src(p("src/angular-material-calendar.html"))
.pipe(htmlmin({ collapseWhitespace: true }))
.pipe(replace("\"", "'"))
.pipe(gulp.dest(p("dist")))
.pipe(gulp.dest(""))
.pipe(connect.reload());
});
gulp.task("js:lint", function() {
return gulp
.src(p("src/angular-material-calendar.js"))
.pipe(eslint())
.pipe(eslint.format());
});
gulp.task("js:lint-ci", function() {
return gulp
.src(p("src/angular-material-calendar.js"))
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failOnError());
});
gulp.task("scss", function() {
return gulp
.src(p("src/**/*.scss"))
.pipe(sass()).on("error", sass.logError)
.pipe(autoprefixer({
browsers: ["last 2 versions"],
cascade: false
}))
.pipe(gulp.dest("dist"))
.pipe(gulp.dest(""))
.pipe(minifyCSS())
.pipe(rename({ suffix: ".min" }))
.pipe(gulp.dest("dist"))
.pipe(gulp.dest(""))
.pipe(connect.reload());
});
gulp.task("karma:tdd", function(done) {
new Karma({
configFile: __dirname + "/karma.conf.js",
singleRun: false
}, done).start();
});
gulp.task("test", ["js:lint-ci"], function() {
connect.server({ root: "website", port: 3000 });
gulp
.src(["./tests/e2e/**/*.spec.js"])
.pipe(protractor({ configFile: p("protractor.conf.js") }))
.on("error", function(e) { throw e; })
.on("end", connect.serverClose);
});
gulp.task("build", function() {
runSequence("scss", "html", "js");
});
gulp.task("connect", function() {
connect.server({ livereload: true, root: "website", port: 3000 });
});
gulp.task("watch", function() {
gulp.watch(p("src/**/*"), ["js:lint", "build"]);
});
gulp.task("default", ["karma:tdd", "connect", "watch"]);