-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpFile.js
100 lines (75 loc) · 2.17 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
var gulp = require("gulp");
var source = require("vinyl-source-stream");
var buffer = require("vinyl-buffer");
var cp = require("child_process");
var stylus = require("gulp-stylus");
var coffeeify = require("coffeeify");
var browserify = require("browserify");
var copy = require("gulp-copy");
var concat = require("gulp-concat");
var util = require("gulp-util");
var paths = {
development: "./development",
distribution: "./distributionribution",
mainElm: "./source/Main.elm",
elm: "./source/**/*.elm",
css: "./source/**/*.styl",
js: "./source/*.js"
};
var production = false;
gulp.task("js", function() {
return browserify("./source/app.js", {
debug: !production,
cache: {},
}).bundle()
.pipe(source("app.js"))
.pipe(buffer())
.pipe(gulp.dest(paths.development));
});
gulp.task("stylus", function() {
return gulp
.src([ "./source/styles/main.styl", paths.css ])
.pipe(concat("style.styl"))
.pipe(stylus())
.pipe(gulp.dest(paths.development));
});
// Uncomment out for automatic formatting
gulp.task("elm", ["elm-format", "elm-make"]);
// gulp.task("elm", ["elm-make"]);
gulp.task("elm-format", function() {
var formatCmd = "elm-format ./source --yes";
cp.exec(formatCmd, function(error, stdout) {})
})
gulp.task("elm-make", function () {
var cmd;
cmd = "elm-make ";
cmd += paths.mainElm;
cmd += " --output ";
cmd += paths.development + "/elm.js";
cp.exec(cmd, function(error, stdout) {
if (error) {
util.log(util.colors.cyan("Elm"),
util.colors.red(String(error))
);
}
var stdout = stdout.slice(0, stdout.length - 1);
stdout.split("\n").forEach(function(line) {
util.log(util.colors.cyan("Elm"), line);
})
});
})
gulp.task("server", function() {
return require("./server")(2984, util.log);
});
gulp.task("distribution", function() {
production = true;
gulp.task("default");
return gulp
.src(paths.development + "/**/*")
.pipe(gulp.dest(paths.distribution));
})
gulp.watch(paths.elm, ["elm"]);
gulp.watch(paths.css, ["stylus"]);
gulp.watch(paths.js, ["js"]);
gulp.watch("development/index.html", ["server"])
gulp.task("default", ["elm", "js", "stylus", "server"]);