-
Notifications
You must be signed in to change notification settings - Fork 53
/
gulpfile.js
94 lines (75 loc) · 2.06 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
const gulp = require("gulp");
const eslint = require("gulp-eslint");
const concat = require("gulp-concat");
const compiler = require("webpack");
const webpack = require("webpack-stream");
const watch = require("gulp-watch");
const karma = require("karma");
const parseConfig = karma.config.parseConfig;
const KarmaServer = karma.Server;
const webpackConfig = require("./webpack.config.js");
const builds = {
bundle: "build/shadergraph.js",
css: "build/shadergraph.css",
};
const css = ["src/**/*.css"];
const files = ["src/**/*.js"];
const test = [
// 'node_modules/three/three.js',
]
.concat(builds.bundle)
.concat(["test/**/*.spec.js"]);
gulp.task("pack", function () {
return gulp
.src("src/index.js")
.pipe(
webpack(webpackConfig, compiler, function (_err, _stats) {
/* Use stats to do more things if needed */
})
)
.pipe(gulp.dest("build/"));
});
gulp.task("css", function () {
return gulp.src(css).pipe(concat(builds.css)).pipe(gulp.dest("./"));
});
gulp.task("lint", function () {
return (
gulp
// Define the source files
.src("src/**/*.js")
.pipe(eslint({}))
// Output the results in the console
.pipe(eslint.format())
);
});
gulp.task("karma", function (done) {
parseConfig(
__dirname + "/karma.conf.js",
{ files: test, singleRun: true },
{ promiseConfig: true, throwErrors: true }
).then(
(karmaConfig) => {
new KarmaServer(karmaConfig, done).start();
done();
},
(_rejectReason) => {}
);
});
gulp.task("watch-karma", function () {
return gulp.src(test).pipe(
karma({
configFile: "karma.conf.js",
action: "watch",
})
);
});
gulp.task("watch-build-watch", function () {
watch(files.concat(css), gulp.series("build"));
});
// Main tasks
const buildTask = gulp.series("pack", "css");
gulp.task("default", buildTask);
gulp.task("build", buildTask);
gulp.task("test", gulp.series("build", "karma"));
gulp.task("watch-build", gulp.series("build", "watch-build-watch"));
gulp.task("watch", gulp.series("watch-build", "watch-karma"));