-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
85 lines (74 loc) · 2.82 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
var gulp = require("gulp");
var babel = require("gulp-babel");
var jshint = require("gulp-jshint");
var nodemon = require("gulp-nodemon");
var uglify = require("gulp-uglify");
var util = require("gulp-util");
var mocha = require("gulp-mocha");
var todo = require("gulp-todo");
var webpack = require("webpack-stream");
var fs = require("fs");
var rev = require("gulp-rev");
var replace = require("gulp-rev-replace");
var clean = require("gulp-rev-dist-clean");
//var nodeInspector = require("gulp-node-inspector");
var rimraf = require('rimraf');
// Clear the old bin first
gulp.task("build", ["build-client", "build-server"]);
gulp.task("clear-bin", function gulpRimraf() {
rimraf.sync('bin', {}, function cb() { console.log('Old bin folder cleared.'); });
});
gulp.task("build-server", ["clear-bin"], function gulpBuildServer() {
return gulp.src(["src/server/**/*.*", "src/server/**/*.js"])
.pipe(babel())
.pipe(gulp.dest("bin/server/"));
});
gulp.task("build-client", ["move-client", "compile-client", "rev-rename", "rev-replace", "rev-clean"]);
gulp.task("move-client", ["clear-bin"], function gulpMoveClient() {
return gulp.src(["src/client/**/*.*", "!client/js/*.js"])
.pipe(gulp.dest("bin/client/"));
});
gulp.task("compile-client", ["move-client"], function gulpBuildClient() {
return gulp.src(["src/client/js/app.js"])
//.pipe(uglify())
.pipe(webpack(require("./webpack.config.js")))
.pipe(babel({
presets: [
["es2015", { "modules": false }]
]
}))
.pipe(gulp.dest("bin/client/js/"));
});
gulp.task("rev-rename", ["compile-client"], function gulpRevRename() {
return gulp.src(["bin/client/**/*.html",
"bin/client/**/*.css",
"bin/client/**/*.js",
"bin/client/**/*.json",
"bin/client/**/*.{jpg,png,jpeg,gif,svg}"])
.pipe(rev())
.pipe(gulp.dest("bin/client/"))
.pipe(rev.manifest({ path: "manifest.json" }))
.pipe(gulp.dest("bin/manifest/"));
});
gulp.task("rev-replace", ["compile-client", "rev-rename"], function gulpRevReplace() {
return gulp.src("bin/client/**/*.{css,js,html}")
.pipe(replace({ manifest: gulp.src("bin/manifest/manifest.json"), }))
.pipe(gulp.dest("bin/client/"));
});
gulp.task('rev-clean', ["compile-client", "rev-rename"], function gulpRevClean() {
return gulp.src(['bin/client/**/*'], {read: false})
.pipe(clean('bin/manifest/manifest.json'));
});
gulp.task("run", ["build"], function gulpRun() {
nodemon({
delay: 1000,
script: "arrasio/src/server/server.js",
cwd: "./",
args: ["config.json"],
ext: "html js css"
})
.on("restart", function gulpRunOnRestart() {
util.log("server restarted!");
});
});
gulp.task("default", ["run"]);