2016-12-29 00:49:51 +02:00
|
|
|
/**
|
|
|
|
* Gulp tasks
|
|
|
|
*/
|
|
|
|
|
|
|
|
import * as gulp from 'gulp';
|
|
|
|
import * as ts from 'gulp-typescript';
|
|
|
|
import * as rimraf from 'rimraf';
|
2017-01-19 21:43:17 +02:00
|
|
|
import * as rename from 'gulp-rename';
|
2020-12-26 03:01:32 +02:00
|
|
|
import * as replace from 'gulp-replace';
|
|
|
|
const terser = require('gulp-terser');
|
|
|
|
const cssnano = require('gulp-cssnano');
|
2017-12-07 19:44:50 +02:00
|
|
|
|
2020-05-23 07:19:31 +03:00
|
|
|
const locales: { [x: string]: any } = require('./locales');
|
2020-01-29 21:37:25 +02:00
|
|
|
const meta = require('./package.json');
|
2017-01-18 09:42:01 +02:00
|
|
|
|
2017-03-01 11:20:53 +02:00
|
|
|
gulp.task('build:ts', () => {
|
2018-02-10 03:27:05 +02:00
|
|
|
const tsProject = ts.createProject('./tsconfig.json');
|
2017-03-01 11:20:53 +02:00
|
|
|
|
|
|
|
return tsProject
|
2016-12-29 00:49:51 +02:00
|
|
|
.src()
|
2016-12-29 02:21:49 +02:00
|
|
|
.pipe(tsProject())
|
2019-01-29 09:13:11 +02:00
|
|
|
.on('error', () => {})
|
2017-03-17 17:01:59 +02:00
|
|
|
.pipe(gulp.dest('./built/'));
|
2017-03-01 11:20:53 +02:00
|
|
|
});
|
2016-12-29 00:49:51 +02:00
|
|
|
|
2018-05-05 19:34:48 +03:00
|
|
|
gulp.task('build:copy:views', () =>
|
|
|
|
gulp.src('./src/server/web/views/**/*').pipe(gulp.dest('./built/server/web/views'))
|
|
|
|
);
|
|
|
|
|
2020-05-09 09:47:20 +03:00
|
|
|
gulp.task('build:copy:fonts', () =>
|
|
|
|
gulp.src('./node_modules/three/examples/fonts/**/*').pipe(gulp.dest('./built/client/assets/fonts/'))
|
|
|
|
);
|
|
|
|
|
2020-12-26 03:01:32 +02:00
|
|
|
gulp.task('build:client:script', () => {
|
|
|
|
return gulp.src(['./src/server/web/boot.js'])
|
|
|
|
.pipe(replace('VERSION', JSON.stringify(meta.version)))
|
|
|
|
.pipe(replace('LANGS', JSON.stringify(Object.keys(locales))))
|
|
|
|
.pipe(terser({
|
|
|
|
toplevel: true
|
|
|
|
}))
|
|
|
|
.pipe(gulp.dest('./built/server/web/'));
|
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task('build:client:style', () => {
|
|
|
|
return gulp.src(['./src/server/web/style.css'])
|
|
|
|
.pipe(cssnano())
|
|
|
|
.pipe(gulp.dest('./built/server/web/'));
|
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task('build:copy', gulp.parallel('build:copy:views', 'build:client:script', 'build:client:style', 'build:copy:fonts', () =>
|
2017-12-16 18:41:22 +02:00
|
|
|
gulp.src([
|
2019-09-21 15:31:38 +03:00
|
|
|
'./src/emojilist.json',
|
2018-05-05 19:34:48 +03:00
|
|
|
'./src/server/web/views/**/*',
|
2017-12-16 18:41:22 +02:00
|
|
|
'./src/**/assets/**/*',
|
2020-01-29 21:37:25 +02:00
|
|
|
'!./src/client/assets/**/*'
|
2017-12-16 18:41:22 +02:00
|
|
|
]).pipe(gulp.dest('./built/'))
|
2019-01-29 09:26:33 +02:00
|
|
|
));
|
2016-12-29 08:04:22 +02:00
|
|
|
|
2016-12-29 00:49:51 +02:00
|
|
|
gulp.task('clean', cb =>
|
|
|
|
rimraf('./built', cb)
|
|
|
|
);
|
|
|
|
|
2019-01-29 09:26:33 +02:00
|
|
|
gulp.task('cleanall', gulp.parallel('clean', cb =>
|
2016-12-29 00:49:51 +02:00
|
|
|
rimraf('./node_modules', cb)
|
2019-01-29 09:26:33 +02:00
|
|
|
));
|
2016-12-29 00:49:51 +02:00
|
|
|
|
2019-01-29 09:26:10 +02:00
|
|
|
gulp.task('copy:client', () =>
|
2017-02-22 17:54:08 +02:00
|
|
|
gulp.src([
|
2017-03-22 09:19:32 +02:00
|
|
|
'./assets/**/*',
|
2018-03-29 14:32:18 +03:00
|
|
|
'./src/client/assets/**/*',
|
2017-02-22 17:54:08 +02:00
|
|
|
])
|
|
|
|
.pipe(rename(path => {
|
2019-04-12 19:43:22 +03:00
|
|
|
path.dirname = path.dirname!.replace('assets', '.');
|
2017-02-22 17:54:08 +02:00
|
|
|
}))
|
2018-03-29 14:32:18 +03:00
|
|
|
.pipe(gulp.dest('./built/client/assets/'))
|
2017-01-13 18:26:39 +02:00
|
|
|
);
|
2016-12-29 00:49:51 +02:00
|
|
|
|
2020-02-06 19:38:02 +02:00
|
|
|
gulp.task('copy:docs', () =>
|
|
|
|
gulp.src([
|
|
|
|
'./src/docs/**/*',
|
|
|
|
])
|
|
|
|
.pipe(gulp.dest('./built/client/assets/docs/'))
|
|
|
|
);
|
|
|
|
|
2019-01-29 09:31:05 +02:00
|
|
|
gulp.task('build:client', gulp.parallel(
|
2020-02-06 19:38:02 +02:00
|
|
|
'copy:client',
|
|
|
|
'copy:docs'
|
2019-01-29 09:31:05 +02:00
|
|
|
));
|
|
|
|
|
|
|
|
gulp.task('build', gulp.parallel(
|
|
|
|
'build:ts',
|
|
|
|
'build:copy',
|
|
|
|
'build:client',
|
|
|
|
));
|
|
|
|
|
|
|
|
gulp.task('default', gulp.task('build'));
|