2023-07-07 19:22:30 +00:00
|
|
|
/**
|
|
|
|
* Gulp tasks
|
|
|
|
*/
|
|
|
|
|
2024-04-08 01:10:23 +00:00
|
|
|
import fs from "fs";
|
|
|
|
import gulp from "gulp";
|
|
|
|
import replace from "gulp-replace";
|
|
|
|
import terser from "gulp-terser";
|
|
|
|
import cssnano from "gulp-cssnano";
|
|
|
|
import rename from "gulp-rename";
|
2023-07-07 19:22:30 +00:00
|
|
|
|
2024-04-08 01:10:23 +00:00
|
|
|
import locales from "./locales/index.ts";
|
|
|
|
import meta from "./package.json" assert { type: "json" };
|
2023-07-07 19:22:30 +00:00
|
|
|
|
|
|
|
gulp.task("copy:client:fonts", () =>
|
2024-04-08 01:10:23 +00:00
|
|
|
gulp
|
|
|
|
.src("./client/node_modules/three/examples/fonts/**/*")
|
|
|
|
.pipe(gulp.dest("./built/_client_dist_/fonts/"))
|
2023-07-07 19:22:30 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
gulp.task("copy:client:locales", (cb) => {
|
2024-04-08 01:10:23 +00:00
|
|
|
fs.mkdirSync("./built/_client_dist_/locales", { recursive: true });
|
2023-07-07 19:22:30 +00:00
|
|
|
|
2024-04-08 01:10:23 +00:00
|
|
|
const v = { _version_: meta.version };
|
2023-07-07 19:22:30 +00:00
|
|
|
|
2024-04-08 01:10:23 +00:00
|
|
|
for (const [lang, locale] of Object.entries(locales)) {
|
|
|
|
fs.writeFileSync(
|
|
|
|
`./built/_client_dist_/locales/${lang}.${meta.version}.json`,
|
|
|
|
JSON.stringify({ ...locale, ...v }),
|
|
|
|
"utf-8"
|
|
|
|
);
|
|
|
|
}
|
2023-07-07 19:22:30 +00:00
|
|
|
|
2024-04-08 01:10:23 +00:00
|
|
|
cb();
|
2023-07-07 19:22:30 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task("build:client:boot_script", () => {
|
2024-04-08 01:10:23 +00:00
|
|
|
return gulp
|
|
|
|
.src(["./assets-be/boot.template.js"])
|
|
|
|
.pipe(replace("LANGS", JSON.stringify(Object.keys(locales))))
|
|
|
|
.pipe(
|
|
|
|
terser({
|
|
|
|
toplevel: true,
|
|
|
|
})
|
|
|
|
)
|
|
|
|
.pipe(rename("boot.js"))
|
|
|
|
.pipe(gulp.dest("./assets-be/template"));
|
2023-07-07 19:22:30 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task("build:client:boot_style", () => {
|
2024-04-08 01:10:23 +00:00
|
|
|
return gulp
|
|
|
|
.src(["./assets-be/style.template.css"])
|
|
|
|
.pipe(
|
|
|
|
cssnano({
|
|
|
|
zindex: false,
|
|
|
|
})
|
|
|
|
)
|
|
|
|
.pipe(rename("style.css"))
|
|
|
|
.pipe(gulp.dest("./assets-be/template"));
|
2023-07-07 19:22:30 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task("build:client:copy_twemoji", () => {
|
2024-04-08 01:10:23 +00:00
|
|
|
return gulp
|
|
|
|
.src(["node_modules/@discordapp/twemoji/dist/svg/*.svg"])
|
|
|
|
.pipe(gulp.dest("./assets-be/twemoji"));
|
2023-07-07 19:22:30 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task(
|
2024-04-08 01:10:23 +00:00
|
|
|
"build",
|
|
|
|
gulp.parallel(
|
|
|
|
"copy:client:locales",
|
|
|
|
"copy:client:fonts",
|
|
|
|
"build:client:boot_script",
|
|
|
|
"build:client:boot_style",
|
|
|
|
"build:client:copy_twemoji"
|
|
|
|
)
|
2023-07-07 19:22:30 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
gulp.task("default", gulp.task("build"));
|
|
|
|
|
|
|
|
gulp.task("watch", () => {
|
2024-04-08 01:10:23 +00:00
|
|
|
gulp.watch(
|
|
|
|
["./packages/*/src/**/*"],
|
|
|
|
{ ignoreInitial: false },
|
|
|
|
gulp.task("build")
|
|
|
|
);
|
2023-07-07 19:22:30 +00:00
|
|
|
});
|