-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathgulpfile.js
executable file
·41 lines (36 loc) · 1.02 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
var gulp = require('gulp');
var runSequence =require('gulp4-run-sequence');
var rimraf = require('gulp-rimraf');
var merge = require('gulp-merge-json');
//监听词条文件变更
gulp.task('i18n-json-merge-watch', function(cb) {
gulp.watch('./src/assets/i18n/parts/*.json', function () {
runSequence(
'i18n-json-merge',
cb
)
});
});
//合并词条
gulp.task('i18n-json-merge', function(cb) {
runSequence(
'i18n-json-clean',
'i18n-zh-json-merge',
'i18n-en-json-merge',
cb
);
});
gulp.task('i18n-json-clean', function() {
return gulp.src('./src/assets/i18n/*.json', { read: false })
.pipe(rimraf({ force: true }));
});
gulp.task('i18n-zh-json-merge', function() {
return gulp.src('./src/assets/i18n/parts/zh*.json')
.pipe(merge({fileName: 'zh.json'}))
.pipe(gulp.dest('./src/assets/i18n/'));
});
gulp.task('i18n-en-json-merge', function() {
return gulp.src('./src/assets/i18n/parts/en*.json')
.pipe(merge({fileName: 'en.json'}))
.pipe(gulp.dest('./src/assets/i18n/'));
});