-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
87 lines (75 loc) · 2.24 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
const gulp = require("gulp");
const concat = require("gulp-concat");
const tslint = require("gulp-tslint");
const sassLint = require("gulp-sass-lint");
const uglify = require("gulp-uglify");
const webpack = require("webpack");
const styleguidist = require("react-styleguidist");
const config = require("./config.js");
gulp.task("assets:dev", ["freqlist"], () => {
return gulp
.src(config.settings.assets.files)
.pipe(concat(`${config.settings.assets.name}.js`))
.pipe(gulp.dest(config.settings.distribution));
});
gulp.task("assets", ["freqlist"], () => {
return gulp
.src(config.settings.assets.files_build)
.pipe(concat(`${config.settings.assets.name}.js`))
.pipe(uglify())
.pipe(gulp.dest(config.settings.distribution));
});
gulp.task("freqlist", () => {
return gulp
.src(config.settings.assets.freqlist)
.pipe(gulp.dest(config.settings.distribution));
});
gulp.task("html", () => {
return gulp
.src(["index.html", "bg1.jpg", "bg2.jpg", "bg3.jpg", "bg4.jpg"])
.pipe(gulp.dest(config.settings.distribution));
});
gulp.task("tslint", () => {
return gulp
.src("src/**/*.+(ts|tsx)")
.pipe(tslint())
.pipe(tslint.report({
summarizeFailureOutput: true
}));
});
gulp.task("sass-lint", () => {
return gulp
.src("style/**/*.s+(a|c)ss")
.pipe(sassLint())
.pipe(sassLint.format())
.pipe(sassLint.failOnError())
});
gulp.task("styleguidist", ["build"], () => {
gulp.watch("src/**/*.+(ts|tsx)", ["tslint"]);
gulp.watch("style/**/*.s+(a|c)ss", ["sass-lint"]);
styleguidist(config.styleguidist).server((err, config) => {
if (err) {
console.log(err);
}
else {
console.log('Listening at http://' + config.serverHost + ':' + config.serverPort);
}
});
});
gulp.task("watch", ["sass-lint", "tslint", "assets:dev", "html"], () => {
gulp.watch("src/**/*.+(ts|tsx)", ["tslint"]);
gulp.watch("style/**/*.s+(a|c)ss", ["sass-lint"]);
return webpack(config.webpack_watch, (error, stats) => {
if (error) {
console.error(error);
}
});
});
gulp.task("build", ["sass-lint", "tslint", "assets", "html"], (callback) => {
return webpack(config.webpack_build, (error, stats) => {
if (error) {
console.error(error);
}
callback();
});
});