forked from thatshaman/Tyria3DApp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
76 lines (69 loc) · 2.09 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
"use strict";
const version = require("./package.json").version;
const browserify = require("browserify");
const gulp = require("gulp");
const source = require("vinyl-source-stream");
const buffer = require("vinyl-buffer");
const sourcemaps = require("gulp-sourcemaps");
const concat = require("gulp-concat");
const log = require("gulplog");
const sass = require("gulp-sass");
const rename = require("gulp-rename");
const uglifyjs = require("uglify-es");
const composer = require("gulp-uglify/composer");
const uglify = composer(uglifyjs, console);
const watch = require("gulp-watch");
const batch = require("gulp-batch");
gulp.task("default", function() {
// set up the browserify instance on a task basis
let b = browserify({
entries: "./src/Tyria3DApp.js",
glob: "./src/**/*.js",
debug: true
});
return (
b
.bundle()
.pipe(source(`T3DAPP-${version}.min.js`))
.pipe(buffer())
.pipe(sourcemaps.init({ loadMaps: true }))
// Add transformation tasks to the pipeline here.
.pipe(uglify())
.on("error", log.error)
.pipe(sourcemaps.write("./"))
.pipe(gulp.dest("./dist/build/"))
);
});
gulp.task("three-bundle", function() {
return gulp
.src([
"./dist/vendor/three/three.js",
"./dist/vendor/three/DDSLoader.js",
"./dist/vendor/three/FirstPersonControls.js",
"./dist/vendor/three/OBJLoader.js",
"./dist/vendor/three/OrbitControls.js",
"./dist/vendor/three/PointerLockControls.js",
"./dist/vendor/three/Projector.js",
"./dist/vendor/three/Raycaster.js",
"./dist/vendor/three/Stats.js",
"./dist/vendor/three/TrackballControls.js"
])
.pipe(concat({ path: "three-bundle.js" }))
.pipe(uglify())
.pipe(gulp.dest("./dist/build/vendor"));
});
gulp.task("sass", function() {
return gulp
.src("./dist/css/sass/main.scss")
.pipe(sass().on("error", sass.logError))
.pipe(rename("__3d.css"))
.pipe(gulp.dest("./dist/css"));
});
gulp.task("watch", function() {
watch(
"./src/**/*.js",
batch(function(events, done) {
gulp.start("t3dapp", done);
})
);
});