This repository was archived by the owner on May 4, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
156 lines (121 loc) · 3.63 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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
var autoprefixer = require("gulp-autoprefixer");
var browserSync = require("browser-sync");
var concat = require("gulp-concat");
var del = require("del");
var filelog = require("gulp-filelog");
var frep = require("gulp-frep");
var gulp = require("gulp");
var minifycss = require("gulp-minify-css");
var pkg = require("./package.json");
var rename = require("gulp-rename");
var runSequence = require("run-sequence");
var sass = require("gulp-sass");
var sourcemaps = require("gulp-sourcemaps");
var ts = require("gulp-typescript");
var tsLint = require("gulp-tslint");
var uglify = require("gulp-uglify");
var vinylPaths = require("vinyl-paths");
var tsd = require("gulp-tsd");
var proxy = "http://wingspan.192.168.1.111.xip.io";
var srcRoot = "file:///Users/Vancura/Repos/Projects/Wingspan/wingspan/src/ts/";
var paths = {
src: "src",
srcTS: "src/ts/**/*.ts",
srcSCSS: "src/scss/**/*.scss",
dist: "dist",
distCSS: "dist/css",
distImages: "dist/images",
distJS: "dist/js",
distJSList: [
"components/phaser/build/custom/phaser-no-physics.js",
"src/js-vendor/box2d-plugin-full-scrambled.js",
"src/js-vendor/particle-storm-scrambled.js",
"dist/js/main.js"
]
};
var tsProject = ts.createProject("tsconfig.json", { typescript: require("typescript") });
gulp.task("styles", function () {
"use strict";
// Compile SCSS.
return gulp.src(paths.srcSCSS)
.pipe(sass({
errLogToConsole: false,
outputStyle: "expanded"
}))
.pipe(autoprefixer("last 2 versions", "safari 6", "ie 10", "opera 12.1", "ios 6", "android 4", "blackberry 10"))
.pipe(rename({
suffix: ".min"
}))
.pipe(minifycss())
.pipe(gulp.dest(paths.distCSS))
.pipe(browserSync.reload({
stream: true
}));
});
gulp.task("tslint", function () {
"use strict";
return gulp.src(paths.srcTS)
.pipe(tsLint({}))
.pipe(tsLint.report("verbose"));
});
gulp.task("scripts-debug", function () {
"use strict";
var patterns = [{
pattern: /%VERSION%/g,
replacement: pkg.version + " (" + new Date().toGMTString() + ")"
}];
var tsResult = tsProject.src()
.pipe(sourcemaps.init())
.pipe(ts(tsProject));
return tsResult.js
.pipe(sourcemaps.write(".", {
sourceRoot: srcRoot,
includeContent: false
}))
.pipe(frep(patterns))
.pipe(gulp.dest("."))
.pipe(browserSync.reload({
stream: true
}));
});
gulp.task("scripts-dist", ["scripts-debug"], function () {
"use strict";
return gulp.src(paths.distJSList)
.pipe(filelog("concat-dist"))
.pipe(concat("main.js"))
.pipe(rename({
suffix: ".min"
}))
.pipe(uglify())
.pipe(gulp.dest(paths.distJS));
});
gulp.task("browser-sync", function () {
"use strict";
browserSync({
proxy: proxy,
logConnections: true,
open: false
});
});
gulp.task("watch", function () {
"use strict";
runSequence("clean", ["styles", "scripts-debug"], "browser-sync");
gulp.watch(paths.srcSCSS, ["styles"]);
gulp.watch(paths.srcTS, ["scripts-debug"]);
});
gulp.task("clean", function () {
"use strict";
return gulp.src(paths.dist)
.pipe(vinylPaths(del));
});
gulp.task("tsd", function (callback) {
"use strict";
tsd({
command: "reinstall",
config: "./tsd.json"
}, callback);
});
gulp.task("default", function (callback) {
"use strict";
runSequence("clean", "tslint", ["styles", "scripts-dist"], callback);
});