-
Notifications
You must be signed in to change notification settings - Fork 3
/
gulpfile.js
125 lines (111 loc) · 3.18 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
121
122
123
124
125
const fs = require('fs')
const path = require('path')
const gulp = require('gulp')
const XEUtils = require('xe-utils')
const del = require('del')
const babel = require('gulp-babel')
const uglify = require('gulp-uglify')
const rename = require('gulp-rename')
const replace = require('gulp-replace')
const merge = require('merge-stream')
const pack = require('./package.json')
const ts = require('gulp-typescript')
const tsconfig = require('./tsconfig.json')
const tsSettings = {
...tsconfig.compilerOptions,
target: 'es2016'
}
const exportModuleName = 'VxeUI'
const esmOutDir = 'es'
const commOutDir = 'lib'
gulp.task('build_escode', function () {
return gulp.src([
'packages_temp/**.ts',
'packages_temp/**/*.ts',
'!packages_temp/index.ts'
])
.pipe(replace('process.env.VUE_APP_VXE_VERSION', `"${pack.version}"`))
.pipe(replace('process.env.VUE_APP_VXE_ENV', 'process.env.NODE_ENV'))
.pipe(ts(tsSettings))
.pipe(gulp.dest(esmOutDir))
})
gulp.task('build_esjs', gulp.series('build_escode', function () {
return gulp.src([
'packages_temp/index.ts'
])
.pipe(replace('process.env.VUE_APP_VXE_VERSION', `"${pack.version}"`))
.pipe(replace('process.env.VUE_APP_VXE_ENV', 'process.env.NODE_ENV'))
.pipe(ts(tsSettings))
.pipe(rename({
basename: 'index',
extname: '.esm.js'
}))
.pipe(gulp.dest(esmOutDir))
}))
gulp.task('build_es_all', gulp.series('build_esjs'))
gulp.task('build_commoncode', function () {
return gulp.src([
'packages_temp/**.ts',
'packages_temp/**/*.ts',
'!packages_temp/index.ts'
])
.pipe(replace('process.env.VUE_APP_VXE_VERSION', `"${pack.version}"`))
.pipe(replace('process.env.VUE_APP_VXE_ENV', 'process.env.NODE_ENV'))
.pipe(ts(tsSettings))
.pipe(babel({
presets: ['@babel/env']
}))
.pipe(gulp.dest(commOutDir))
.pipe(uglify())
.pipe(rename({
suffix: '.min',
extname: '.js'
}))
.pipe(gulp.dest(commOutDir))
})
gulp.task('build_commonjs', gulp.series('build_commoncode', function () {
return gulp.src([
'packages_temp/index.ts'
])
.pipe(replace('process.env.VUE_APP_VXE_VERSION', `"${pack.version}"`))
.pipe(replace('process.env.VUE_APP_VXE_ENV', 'process.env.NODE_ENV'))
.pipe(ts(tsSettings))
.pipe(babel({
presets: ['@babel/env']
}))
.pipe(rename({
basename: 'index',
extname: '.common.js'
}))
.pipe(gulp.dest(commOutDir))
}))
gulp.task('build_common_all', gulp.series('build_commonjs'))
gulp.task('build_umdjs', () => {
return gulp.src('lib_temp/index.umd.js')
.pipe(gulp.dest('lib'))
.pipe(uglify())
.pipe(rename({
basename: 'index',
extname: '.umd.min.js'
}))
.pipe(gulp.dest('lib'))
})
gulp.task('build_umd_all', gulp.parallel('build_umdjs'))
gulp.task('copy_pack', () => {
return gulp.src('packages/**')
.pipe(gulp.dest('packages_temp'))
})
gulp.task('clear', () => {
return del([
commOutDir,
esmOutDir,
'packages_temp'
])
})
gulp.task('build_all', gulp.parallel('build_es_all', 'build_common_all', 'build_umd_all'))
gulp.task('build', gulp.series('clear', 'copy_pack', 'build_all', () => {
return del([
'lib_temp',
'packages_temp'
])
}))