Newer
Older
open-logistic-tycoon / gulpfile.js
const gulp = require("gulp");
const sass = require("gulp-sass")(require("sass"));
const sourcemaps = require("gulp-sourcemaps");
const watch = require("gulp-watch");
const cleanCSS = require("gulp-clean-css");
const concat = require("gulp-concat");
const uglify = require("gulp-uglify");

gulp.task("sass-build", () => {
	return gulp.src("./game/resources/scss/game.scss")
		.pipe(sourcemaps.init())
		.pipe(sass().on("error", sass.logError))
		.pipe(concat("dist.min.css"))
		.pipe(cleanCSS())
		.pipe(sourcemaps.write("./"))
		.pipe(gulp.dest("./game/resources/"));
});

gulp.task("js-build", () => {
	return gulp.src(["./game/**/*.js", "./engine/**/*.js"])
		.pipe(sourcemaps.init())
		.pipe(concat("app.js"))
		.pipe(uglify())
		.pipe(sourcemaps.write("./"))
		.pipe(gulp.dest("./"));
});

// gulp.task("build-release-sass", () => {
// 	return gulp.src("./assets/olainfarm/scss/index.scss")
// 		.pipe(sass().on("error", sass.logError))
// 		.pipe(concat("olainfarm.min.css"))
// 		.pipe(cleanCSS())
// 		.pipe(gulp.dest("./css/"));
// });

// gulp.task("build-release-js", () => {
// 	return gulp.src("./js/*.js")
// 		.pipe(concat("olainfarm.min.js"))
// 		.pipe(uglify())
// 		.pipe(gulp.dest("./assets/olainfarm/js/olainfarm/dist"));
// });

// async function cleanMaps() {
//   const { deleteAsync } = await import('del');
//   return deleteAsync(["./assets/js/olainfarm/dist/*.map", "./assets/css/*.map"]);
// }

// gulp.task("clean-maps", cleanMaps);

// gulp.task("build-release", gulp.series("build-release-sass", "build-release-js", "clean-maps"));

gulp.task("watch", () => {
	gulp.watch("./game/resources/**/*.scss", gulp.series("sass-build"));
	gulp.watch(["./game/**/*.js", "./engine/**/*.js"], gulp.series("js-build"));
});