-
Notifications
You must be signed in to change notification settings - Fork 4
/
gulpfile.js
50 lines (46 loc) · 1.24 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
const gulp = require('gulp')
const uglify = require('gulp-uglify')
const babel = require('gulp-babel')
const rename = require('gulp-rename')
const replace = require('gulp-replace')
const pack = require('./package.json')
const exportModuleName = 'VXEUtils'
gulp.task('build_common', function () {
return gulp.src('index.js')
.pipe(babel({
presets: ['@babel/env']
}))
.pipe(rename({
basename: pack.name,
extname: '.common.js'
}))
.pipe(gulp.dest('dist'))
})
gulp.task('build_umd', function () {
return gulp.src('index.js')
.pipe(babel({
moduleId: pack.name,
presets: ['@babel/env'],
plugins: [['@babel/transform-modules-umd', {
globals: {
[pack.name]: exportModuleName
},
exactGlobals: true
}]]
}))
.pipe(replace(`global.${exportModuleName} = mod.exports;`, `global.${exportModuleName} = mod.exports.default;`))
.pipe(rename({
basename: pack.name,
suffix: '.umd',
extname: '.js'
}))
.pipe(gulp.dest('dist'))
.pipe(uglify())
.pipe(rename({
basename: pack.name,
suffix: '.umd.min',
extname: '.js'
}))
.pipe(gulp.dest('dist'))
})
gulp.task('build', gulp.parallel('build_common', 'build_umd'))