-
Notifications
You must be signed in to change notification settings - Fork 10
/
gulpfile.js
76 lines (71 loc) · 1.88 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 gulp = require('gulp')
const del = require('del')
const uglify = require('gulp-uglify')
const babel = require('gulp-babel')
const rename = require('gulp-rename')
const replace = require('gulp-replace')
const dartSass = require('sass')
const gulpSass = require('gulp-sass')
const sass = gulpSass(dartSass)
const cleanCSS = require('gulp-clean-css')
const prefixer = require('gulp-autoprefixer')
const sourcemaps = require('gulp-sourcemaps')
const ts = require('gulp-typescript')
const pack = require('./package.json')
const tsconfig = require('./tsconfig.json')
const exportModuleName = 'VXETablePluginExportPDF'
gulp.task('build_commonjs', function () {
return gulp.src(['index.ts'])
// .pipe(sourcemaps.init())
.pipe(ts(tsconfig.compilerOptions))
.pipe(babel({
presets: ['@babel/env']
}))
.pipe(rename({
basename: 'index',
extname: '.common.js'
}))
// .pipe(sourcemaps.write())
.pipe(gulp.dest('dist'))
})
gulp.task('build_umd', function () {
return gulp.src(['index.ts'])
.pipe(ts(tsconfig.compilerOptions))
.pipe(babel({
moduleId: pack.name,
presets: [
'@babel/env'
],
plugins: [
['@babel/transform-modules-umd', {
globals: {
[pack.name]: exportModuleName,
'vue': 'Vue',
'vxe-table': 'VXETable',
'xe-utils': 'XEUtils',
jspdf: 'jspdf'
},
exactGlobals: true
}]
]
}))
.pipe(rename({
basename: 'index',
suffix: '.umd',
extname: '.js'
}))
.pipe(gulp.dest('dist'))
.pipe(uglify())
.pipe(rename({
basename: 'index',
suffix: '.umd.min',
extname: '.js'
}))
.pipe(gulp.dest('dist'))
})
gulp.task('clear', () => {
return del([
'dist/depend.*'
])
})
gulp.task('build', gulp.series(gulp.parallel('build_commonjs', 'build_umd'), 'clear'))