-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathgulpfile.js
executable file
·120 lines (110 loc) · 3.27 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
'use strict';
const gulp = require('gulp');
const babel = require('gulp-babel');
const uglify = require('gulp-uglify');
const concat = require('gulp-concat');
const plumber = require('gulp-plumber');
const postcss = require('gulp-postcss');
const autoprefixer = require('autoprefixer');
const cssnano = require('cssnano');
const sass = require('gulp-sass')(require('sass'));
const rename = require('gulp-rename');
const ts = require('gulp-typescript');
var pxtorem = require('postcss-pxtorem');
function css() {
return gulp
.src('./scss/app.scss')
.pipe(plumber())
.pipe(
sass({
outputStyle: 'compressed',
allowEmpty: true,
silenceDeprecations: ['legacy-js-api'],
})
)
.pipe(rename('misc.css'))
.pipe(postcss([autoprefixer(), cssnano()]))
.pipe(gulp.dest('./build/css/'));
}
function images() {
return gulp.src('./images/*.{png,jpg,gif,svg}').pipe(gulp.dest('./build/images/'));
}
function fonts() {
return gulp.src('./fonts/*').pipe(gulp.dest('./build/fonts/'));
}
function settingCSS() {
return gulp
.src('./scss/setting.scss')
.pipe(
sass({
outputStyle: 'compressed',
allowEmpty: true,
silenceDeprecations: ['legacy-js-api'],
})
)
.pipe(postcss([autoprefixer(), cssnano()]))
.pipe(gulp.dest('./build/css/'));
}
function typescripts() {
return (
gulp
.src([
// './ts/modules/helper.ts',
'./ts/app.ts',
// './ts/modules/db.ts',
// './ts/modules/lazy.ts',
// './ts/modules/map.ts',
'./ts/modules/zoom.ts',
'./ts/modules/action.ts',
'./ts/modules/comment.ts',
'./ts/modules/scroll.ts',
'./ts/modules/date.ts',
])
.pipe(
ts({
noImplicitAny: true,
outFile: 'ts.js',
})
)
//.pipe(uglify())
.pipe(gulp.dest('build/js/'))
);
}
function setting() {
return gulp
.src(['./ts/extensions/*', './ts/setting.ts'])
.pipe(plumber())
.pipe(
ts({
noImplicitAny: true,
outFile: 'setting.js',
target: 'es5',
})
)
.pipe(uglify())
.pipe(rename({ suffix: '.min' }))
.pipe(gulp.dest('./build/js/'));
}
// Watch files
function watchFiles() {
gulp.watch(
['./scss/app.scss', './scss/components/*', './scss/base/*', './scss/templates/*'],
gulp.series(css)
);
gulp.watch(['./scss/setting.scss'], gulp.series(settingCSS));
gulp.watch(['./ts/app.ts', './ts/modules/*'], gulp.series(typescripts));
gulp.watch(['./ts/setting.ts'], gulp.series(setting));
}
// define complex tasks
const watch = gulp.parallel(watchFiles);
const build = gulp.parallel(
watch,
gulp.parallel(css, setting, images, fonts, typescripts, settingCSS)
);
exports.setting = setting;
exports.css = css;
exports.settingCSS = settingCSS;
exports.typescripts = typescripts;
exports.build = build;
exports.watch = watch;
exports.default = build;