Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var gulp = require("gulp"),
- babel = require("gulp-babel"),
- concat = require("gulp-concat"),
- minify = require("gulp-minify"),
- rename = require("gulp-rename"),
- watch = require("gulp-watch"),
- plumber = require("gulp-plumber"),
- runSequence = require("run-sequence"),
- browserSync = require("browser-sync"),
- del = require("del");
- gulp.task("default", (cb) => {
- runSequence("engine", "game", "copy:lib", "copy:shaders", "copy:assets", "copy:html", "copy:css", "webserver", "watch", cb);
- });
- gulp.task("watch", () => {
- gulp.watch("app/js/engine/**", ["engine"]);
- gulp.watch("app/js/game/**", ["game"]);
- gulp.watch("app/lib/**", ["copy:lib"]);
- gulp.watch("app/js/shaders/*.glsl", ["copy:shaders"]);
- gulp.watch("app/assets/**", ["copy:assets"]);
- gulp.watch("app/index.html", ["copy:html"]);
- gulp.watch("app/css/**", ["copy:css"]);
- });
- gulp.task("webserver", () => {
- var _browser_URL = "./dist",
- port = 80,
- host = "localhost";
- browserSync({
- server: _browser_URL,
- port: port,
- host: host
- });
- });
- gulp.task("engine", () => {
- return gulp.src("app/js/engine/**")
- .pipe(plumber())
- // .pipe(babel({ presets: ["es2015"] }))
- .pipe(gulp.dest("dist/js/engine"))
- .pipe(browserSync.reload({ stream: true }));
- });
- gulp.task("game", () => {
- return gulp.src("app/js/game/**")
- .pipe(plumber())
- // .pipe(babel({ presets: ["es2015"] }))
- .pipe(gulp.dest("dist/js/game"))
- .pipe(browserSync.reload({ stream: true }));
- });
- gulp.task("copy:lib", () => {
- gulp.src("app/lib/**")
- .pipe(gulp.dest("dist/lib"))
- .pipe(browserSync.reload({ stream: true }));
- });
- gulp.task("copy:shaders", () => {
- gulp.src("app/js/shaders/*.glsl")
- .pipe(gulp.dest("dist/shaders"))
- .pipe(browserSync.reload({ stream: true }));
- });
- gulp.task("copy:assets", () => {
- gulp.src("app/assets/**")
- .pipe(gulp.dest("dist/assets"))
- .pipe(browserSync.reload({ stream: true }));
- });
- gulp.task("copy:html", () => {
- gulp.src("app/index.html")
- .pipe(plumber())
- .pipe(gulp.dest("dist"))
- .pipe(browserSync.reload({ stream: true }));
- });
- gulp.task("copy:css", () => {
- gulp.src("app/css/**")
- .pipe(gulp.dest("dist/css"))
- .pipe(browserSync.reload({ stream: true }));
- });
- gulp.task("clean", function(cb) {
- console.log("Cleaning");
- del([
- "dist/**"
- ], cb);
- });
- ////////////////////
- // //
- // BUILD TASK //
- // //
- ////////////////////
- gulp.task("build", (cb) => {
- runSequence("build:engine", "build:game", "build:lib", "build:shaders", "build:assets", "build:html", "build:css", cb);
- });
- gulp.task("build:engine", () => {
- return gulp.src(["app/js/engine/Cow.js",
- "app/js/engine/gl.js",
- "app/js/engine/System.js",
- "app/js/engine/Entities.js",
- "app/js/engine/Transform.js",
- "app/js/engine/Camera.js",
- "app/js/engine/Collisions.js",
- "app/js/engine/Loader.js",
- "app/js/engine/Render.js",
- "app/js/engine/Input.js",
- "app/js/engine/Network.js",
- "app/js/engine/Scenes.js",
- "app/js/engine/Scene.js",
- "app/js/engine/Component.js",
- "app/js/engine/Entity.js",
- "app/js/engine/defaultComponents/**"])
- .pipe(plumber())
- .pipe(concat("Cow.js"))
- .pipe(babel({ presets: ["es2015"] }))
- .pipe(minify())
- .pipe(gulp.dest("build/js"));
- });
- gulp.task("build:game", () => {
- return gulp.src("app/js/game/**/*.js")
- .pipe(plumber())
- .pipe(concat("game.js"))
- .pipe(babel({ presets: ["es2015"] }))
- .pipe(minify())
- .pipe(gulp.dest("build/js"));
- });
- gulp.task("build:shaders", () => {
- return gulp.src("app/js/shaders/*.glsl")
- .pipe(plumber())
- .pipe(gulp.dest("build/shaders"));
- });
- gulp.task("build:lib", () => {
- return gulp.src("app/lib/**")
- .pipe(plumber())
- .pipe(gulp.dest("build/lib"));
- });
- gulp.task("build:assets", () => {
- return gulp.src("app/assets/**")
- .pipe(plumber())
- .pipe(gulp.dest("build/assets"));
- });
- gulp.task("build:html", () => {
- return gulp.src("app/index-build.html")
- .pipe(plumber())
- .pipe(rename("index.html"))
- .pipe(gulp.dest("build"));
- });
- gulp.task("build:css", () => {
- return gulp.src("app/css/*.css")
- .pipe(plumber())
- .pipe(gulp.dest("build/css"));
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement