-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
76 lines (65 loc) · 2.37 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
const { src, dest, series, parallel, watch } = require('gulp');
const sass = require('gulp-sass')(require('sass'));
const concat = require('gulp-concat');
const cleanCSS = require('gulp-clean-css');
const webp = require('gulp-webp');
const del = require('del');
const gulpWebp = require('gulp-webp');
const rename = require('gulp-rename');
const filelist = require('gulp-filelist');
const path = require('path');
const jsdoc = require('gulp-jsdoc3');
const zip = require('gulp-zip');
const PROJECT_TECH_NAME = 'rnd-npcs';
async function buildCSS() {
return src('./src/styles/**/*.scss')
.pipe(sass().on('error', sass.logError))
.pipe(concat(`${PROJECT_TECH_NAME}.css`))
.pipe(cleanCSS())
.pipe(dest('./build'));
};
async function copyImages()
{
return src(['./src/img/**/*.png', './src/img/**/*.jpg', './src/img/**/*.tiff'])
.pipe(webp({quality: 90, alphaQuality: 100, method: 6, metadata: 'icc'}))
.pipe(dest('./build/assets/img'));
}
async function copyStatic()
{
return src('./src/static/**')
.pipe(dest('./build'));
}
async function clean()
{
return del(['build/**', '!build']);
}
async function buildTemplateList()
{
return src('./src/static/templates/**/*.hbs')
.pipe(rename(filePath => filePath.dirname = path.join(`modules/${PROJECT_TECH_NAME}/templates`, filePath.dirname)))
.pipe(filelist('templateList.json', { relative: true }))
.pipe(dest('build/data'));
}
async function buildDocumentation()
{
const config = require('./jsdoc.json');
return src(['README.md', './src/static/module/**/*.js'], {read: false})
.pipe(jsdoc(config));
}
async function zipBuild()
{
return src('./build/**')
.pipe(zip(`${PROJECT_TECH_NAME}.zip`))
.pipe(dest('dists'));
}
async function buildWatch()
{
watch('src/styles/**/*.scss', { ignoreInitial: false }, buildCSS);
watch('src/img/**', { ignoreInitial: false }, copyImages);
watch('src/static/**', { ignoreInitial: false }, copyStatic);
watch('./src/static/templates/**/*.hbs', { ignoreInitial: false }, buildTemplateList);
watch(['README.md', './src/static/module/**/*.js'], {ignoreInitial: false}, buildDocumentation);
}
exports.build = series(clean, parallel(buildCSS, copyImages, copyStatic, buildTemplateList, buildDocumentation));
exports.buildWatch = series(clean, buildWatch);
exports.zipbuild = series(zipBuild);