2021-11-11 10:02:25 -07:00
|
|
|
/**
|
|
|
|
* 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');
|
|
|
|
|
|
|
|
gulp.task('copy:backend:views', () =>
|
|
|
|
gulp.src('./packages/backend/src/server/web/views/**/*').pipe(gulp.dest('./packages/backend/built/server/web/views'))
|
|
|
|
);
|
|
|
|
|
2022-08-09 03:37:12 -06:00
|
|
|
gulp.task('copy:backend:custom', () =>
|
|
|
|
gulp.src('./custom/*').pipe(gulp.dest('./packages/backend/assets/'))
|
|
|
|
);
|
|
|
|
|
2021-11-11 10:02:25 -07:00
|
|
|
gulp.task('copy:client:fonts', () =>
|
|
|
|
gulp.src('./packages/client/node_modules/three/examples/fonts/**/*').pipe(gulp.dest('./built/_client_dist_/fonts/'))
|
|
|
|
);
|
|
|
|
|
2022-11-06 18:33:52 -07:00
|
|
|
gulp.task('copy:client:phosphor', () =>
|
2022-11-06 20:44:26 -07:00
|
|
|
gulp.src('./node_modules/phosphor-icons/src/css/*').pipe(gulp.dest('./built/_client_dist_/phosphor/'))
|
2022-02-08 21:23:29 -07:00
|
|
|
);
|
|
|
|
|
2021-11-11 10:02:25 -07:00
|
|
|
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();
|
|
|
|
});
|
|
|
|
|
2022-08-09 03:37:12 -06:00
|
|
|
|
2021-11-11 10:02:25 -07:00
|
|
|
gulp.task('build:backend:script', () => {
|
|
|
|
return gulp.src(['./packages/backend/src/server/web/boot.js', './packages/backend/src/server/web/bios.js', './packages/backend/src/server/web/cli.js'])
|
|
|
|
.pipe(replace('LANGS', JSON.stringify(Object.keys(locales))))
|
|
|
|
.pipe(terser({
|
|
|
|
toplevel: true
|
|
|
|
}))
|
|
|
|
.pipe(gulp.dest('./packages/backend/built/server/web/'));
|
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task('build:backend:style', () => {
|
|
|
|
return gulp.src(['./packages/backend/src/server/web/style.css', './packages/backend/src/server/web/bios.css', './packages/backend/src/server/web/cli.css'])
|
|
|
|
.pipe(cssnano({
|
|
|
|
zindex: false
|
|
|
|
}))
|
|
|
|
.pipe(gulp.dest('./packages/backend/built/server/web/'));
|
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task('build', gulp.parallel(
|
2022-11-06 18:33:52 -07:00
|
|
|
'copy:client:locales', 'copy:backend:views', 'copy:backend:custom', 'build:backend:script', 'build:backend:style', 'copy:client:fonts', 'copy:client:phosphor'
|
2021-11-11 10:02:25 -07:00
|
|
|
));
|
|
|
|
|
|
|
|
gulp.task('default', gulp.task('build'));
|
|
|
|
|
|
|
|
gulp.task('watch', () => {
|
|
|
|
gulp.watch([
|
2021-11-18 22:48:59 -07:00
|
|
|
'./packages/*/src/**/*',
|
2021-11-11 10:02:25 -07:00
|
|
|
], { ignoreInitial: false }, gulp.task('build'));
|
|
|
|
});
|