96 lines
1.9 KiB
JavaScript
96 lines
1.9 KiB
JavaScript
/**
|
|
* Gulp tasks
|
|
*/
|
|
|
|
const fs = require("fs");
|
|
const gulp = require("gulp");
|
|
const replace = require("gulp-replace");
|
|
const terser = require("gulp-terser");
|
|
const cssnano = require("gulp-cssnano");
|
|
|
|
const locales = require("./locales");
|
|
const meta = require("./package.json");
|
|
const rename = require("gulp-rename");
|
|
|
|
gulp.task("copy:client:fonts", () =>
|
|
gulp
|
|
.src("./packages/client/node_modules/three/examples/fonts/**/*")
|
|
.pipe(gulp.dest("./built/_client_dist_/fonts/")),
|
|
);
|
|
|
|
gulp.task("copy:client:locales", (cb) => {
|
|
fs.mkdirSync("./built/_client_dist_/locales", { recursive: true });
|
|
|
|
const v = { _version_: meta.version };
|
|
|
|
for (const [lang, locale] of Object.entries(locales)) {
|
|
fs.writeFileSync(
|
|
`./built/_client_dist_/locales/${lang}.${meta.version}.json`,
|
|
JSON.stringify({ ...locale, ...v }),
|
|
"utf-8",
|
|
);
|
|
}
|
|
|
|
cb();
|
|
});
|
|
|
|
gulp.task("build:client:boot_script", () => {
|
|
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"));
|
|
});
|
|
|
|
gulp.task("build:client:boot_style", () => {
|
|
return gulp
|
|
.src([
|
|
"./assets-be/style.template.css",
|
|
])
|
|
.pipe(
|
|
cssnano({
|
|
zindex: false,
|
|
}),
|
|
)
|
|
.pipe(rename('style.css'))
|
|
.pipe(gulp.dest("./assets-be/template"));
|
|
});
|
|
|
|
gulp.task("build:client:copy_twemoji", () => {
|
|
return gulp
|
|
.src([
|
|
"node_modules/@discordapp/twemoji/dist/svg/*.svg"
|
|
])
|
|
.pipe(gulp.dest("./assets-be/twemoji"));
|
|
|
|
});
|
|
|
|
|
|
gulp.task(
|
|
"build",
|
|
gulp.parallel(
|
|
"copy:client:locales",
|
|
"copy:client:fonts",
|
|
"build:client:boot_script",
|
|
"build:client:boot_style",
|
|
"build:client:copy_twemoji"
|
|
),
|
|
);
|
|
|
|
gulp.task("default", gulp.task("build"));
|
|
|
|
gulp.task("watch", () => {
|
|
gulp.watch(
|
|
["./packages/*/src/**/*"],
|
|
{ ignoreInitial: false },
|
|
gulp.task("build"),
|
|
);
|
|
});
|