2016-12-29 07:49:51 +09:00
|
|
|
/**
|
|
|
|
* Gulp tasks
|
|
|
|
*/
|
|
|
|
|
2020-01-30 04:37:25 +09:00
|
|
|
import * as fs from 'fs';
|
2016-12-29 07:49:51 +09:00
|
|
|
import * as gulp from 'gulp';
|
|
|
|
import * as ts from 'gulp-typescript';
|
|
|
|
import * as rimraf from 'rimraf';
|
2017-01-20 04:43:17 +09:00
|
|
|
import * as rename from 'gulp-rename';
|
2019-12-12 00:37:58 +09:00
|
|
|
const cleanCSS = require('gulp-clean-css');
|
2020-01-30 04:37:25 +09:00
|
|
|
const sass = require('gulp-dart-sass');
|
|
|
|
const fiber = require('fibers');
|
2017-12-08 02:44:50 +09:00
|
|
|
|
2018-07-06 12:17:38 +09:00
|
|
|
const locales = require('./locales');
|
2020-01-30 04:37:25 +09:00
|
|
|
const meta = require('./package.json');
|
2017-01-18 16:42:01 +09:00
|
|
|
|
2017-03-01 18:20:53 +09:00
|
|
|
gulp.task('build:ts', () => {
|
2018-02-10 10:27:05 +09:00
|
|
|
const tsProject = ts.createProject('./tsconfig.json');
|
2017-03-01 18:20:53 +09:00
|
|
|
|
|
|
|
return tsProject
|
2016-12-29 07:49:51 +09:00
|
|
|
.src()
|
2016-12-29 09:21:49 +09:00
|
|
|
.pipe(tsProject())
|
2019-01-29 16:13:11 +09:00
|
|
|
.on('error', () => {})
|
2017-03-18 00:01:59 +09:00
|
|
|
.pipe(gulp.dest('./built/'));
|
2017-03-01 18:20:53 +09:00
|
|
|
});
|
2016-12-29 07:49:51 +09:00
|
|
|
|
2018-05-06 01:34:48 +09:00
|
|
|
gulp.task('build:copy:views', () =>
|
|
|
|
gulp.src('./src/server/web/views/**/*').pipe(gulp.dest('./built/server/web/views'))
|
|
|
|
);
|
|
|
|
|
2020-01-30 04:37:25 +09:00
|
|
|
gulp.task('build:copy:locales', cb => {
|
|
|
|
fs.mkdirSync('./built/client/assets/locales', { recursive: true });
|
2019-08-18 14:41:33 +09:00
|
|
|
|
2020-01-30 04:37:25 +09:00
|
|
|
for (const [lang, locale] of Object.entries(locales)) {
|
|
|
|
fs.writeFileSync(`./built/client/assets/locales/${lang}.${meta.version}.json`, JSON.stringify(locale), 'utf-8');
|
|
|
|
}
|
|
|
|
|
|
|
|
cb();
|
|
|
|
});
|
|
|
|
|
2020-05-09 15:47:20 +09:00
|
|
|
gulp.task('build:copy:fonts', () =>
|
|
|
|
gulp.src('./node_modules/three/examples/fonts/**/*').pipe(gulp.dest('./built/client/assets/fonts/'))
|
|
|
|
);
|
|
|
|
|
|
|
|
gulp.task('build:copy', gulp.parallel('build:copy:views', 'build:copy:locales', 'build:copy:fonts', () =>
|
2017-12-17 01:41:22 +09:00
|
|
|
gulp.src([
|
2019-09-21 21:31:38 +09:00
|
|
|
'./src/emojilist.json',
|
2018-05-06 01:34:48 +09:00
|
|
|
'./src/server/web/views/**/*',
|
2017-12-17 01:41:22 +09:00
|
|
|
'./src/**/assets/**/*',
|
2020-01-30 04:37:25 +09:00
|
|
|
'!./src/client/assets/**/*'
|
2017-12-17 01:41:22 +09:00
|
|
|
]).pipe(gulp.dest('./built/'))
|
2019-01-29 16:26:33 +09:00
|
|
|
));
|
2016-12-29 15:04:22 +09:00
|
|
|
|
2016-12-29 07:49:51 +09:00
|
|
|
gulp.task('clean', cb =>
|
|
|
|
rimraf('./built', cb)
|
|
|
|
);
|
|
|
|
|
2019-01-29 16:26:33 +09:00
|
|
|
gulp.task('cleanall', gulp.parallel('clean', cb =>
|
2016-12-29 07:49:51 +09:00
|
|
|
rimraf('./node_modules', cb)
|
2019-01-29 16:26:33 +09:00
|
|
|
));
|
2016-12-29 07:49:51 +09:00
|
|
|
|
2017-01-14 01:26:39 +09:00
|
|
|
gulp.task('build:client:styles', () =>
|
2020-01-30 04:37:25 +09:00
|
|
|
gulp.src('./src/client/style.scss')
|
|
|
|
.pipe(sass({ fiber }))
|
2019-12-12 00:37:58 +09:00
|
|
|
.pipe(cleanCSS())
|
2018-03-29 20:32:18 +09:00
|
|
|
.pipe(gulp.dest('./built/client/assets/'))
|
2017-01-14 01:26:39 +09:00
|
|
|
);
|
2016-12-29 07:49:51 +09:00
|
|
|
|
2019-01-29 16:26:10 +09:00
|
|
|
gulp.task('copy:client', () =>
|
2017-02-23 00:54:08 +09:00
|
|
|
gulp.src([
|
2017-03-22 16:19:32 +09:00
|
|
|
'./assets/**/*',
|
2018-03-29 20:32:18 +09:00
|
|
|
'./src/client/assets/**/*',
|
2017-02-23 00:54:08 +09:00
|
|
|
])
|
|
|
|
.pipe(rename(path => {
|
2019-04-13 01:43:22 +09:00
|
|
|
path.dirname = path.dirname!.replace('assets', '.');
|
2017-02-23 00:54:08 +09:00
|
|
|
}))
|
2018-03-29 20:32:18 +09:00
|
|
|
.pipe(gulp.dest('./built/client/assets/'))
|
2017-01-14 01:26:39 +09:00
|
|
|
);
|
2016-12-29 07:49:51 +09:00
|
|
|
|
2020-02-07 02:38:02 +09:00
|
|
|
gulp.task('copy:docs', () =>
|
|
|
|
gulp.src([
|
|
|
|
'./src/docs/**/*',
|
|
|
|
])
|
|
|
|
.pipe(gulp.dest('./built/client/assets/docs/'))
|
|
|
|
);
|
|
|
|
|
2019-01-29 16:31:05 +09:00
|
|
|
gulp.task('build:client', gulp.parallel(
|
|
|
|
'build:client:styles',
|
2020-02-07 02:38:02 +09:00
|
|
|
'copy:client',
|
|
|
|
'copy:docs'
|
2019-01-29 16:31:05 +09:00
|
|
|
));
|
|
|
|
|
|
|
|
gulp.task('build', gulp.parallel(
|
|
|
|
'build:ts',
|
|
|
|
'build:copy',
|
|
|
|
'build:client',
|
|
|
|
));
|
|
|
|
|
|
|
|
gulp.task('default', gulp.task('build'));
|