2020-11-02 14:25:25 +08:00
|
|
|
const { task, src, dest, series, watch } = require("gulp");
|
|
|
|
const concat = require("gulp-concat");
|
|
|
|
const del = require("del");
|
|
|
|
const vinylPaths = require("vinyl-paths");
|
2020-11-02 14:53:20 +08:00
|
|
|
var sass = require("gulp-sass");
|
|
|
|
sass.compiler = require("dart-sass");
|
2020-11-02 14:25:25 +08:00
|
|
|
|
2020-11-02 15:06:30 +08:00
|
|
|
//the order of files is important
|
2020-11-02 14:25:25 +08:00
|
|
|
const gulpSrc = [
|
2020-11-02 15:06:30 +08:00
|
|
|
"./src/js/misc.js",
|
|
|
|
"./src/js/words.js",
|
|
|
|
"./src/js/layouts.js",
|
|
|
|
"./src/js/db.js",
|
|
|
|
"./src/js/userconfig.js",
|
|
|
|
"./src/js/commandline.js",
|
|
|
|
"./src/js/leaderboards.js",
|
|
|
|
"./src/js/settings.js",
|
|
|
|
"./src/js/account.js",
|
|
|
|
"./src/js/script.js",
|
2020-11-02 14:25:25 +08:00
|
|
|
];
|
|
|
|
|
|
|
|
task("cat", function () {
|
2020-11-02 19:19:24 +08:00
|
|
|
return src(gulpSrc).pipe(concat("monkeytype.js")).pipe(dest("./dist/js"));
|
2020-11-02 14:25:25 +08:00
|
|
|
});
|
|
|
|
|
2020-11-02 14:53:20 +08:00
|
|
|
task("sass", function () {
|
2020-11-02 15:06:30 +08:00
|
|
|
return src("./src/sass/*.scss")
|
2020-11-02 14:53:20 +08:00
|
|
|
.pipe(sass({ outputStyle: "compressed" }).on("error", sass.logError))
|
2020-11-02 19:19:24 +08:00
|
|
|
.pipe(dest("dist/css"));
|
2020-11-02 14:53:20 +08:00
|
|
|
});
|
|
|
|
|
2020-11-02 19:19:24 +08:00
|
|
|
task("static", function () {
|
2020-11-04 09:01:39 +08:00
|
|
|
return src("./static/**/*").pipe(dest("./dist/"));
|
2020-11-02 14:25:25 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
task("clean", function () {
|
2020-11-02 19:19:24 +08:00
|
|
|
return src("./dist/", { allowEmpty: true }).pipe(vinylPaths(del));
|
2020-11-02 14:25:25 +08:00
|
|
|
});
|
|
|
|
|
2020-11-03 09:43:42 +08:00
|
|
|
task("compile", series("static", "sass", "cat"));
|
2020-11-02 14:25:25 +08:00
|
|
|
|
|
|
|
task("watch", function () {
|
2020-11-04 09:01:39 +08:00
|
|
|
watch(["./static/**/*", "./src/**/*"], series("compile"));
|
2020-11-02 14:25:25 +08:00
|
|
|
});
|
|
|
|
|
2020-11-03 09:43:42 +08:00
|
|
|
task("build", series("clean", "compile"));
|