-
Notifications
You must be signed in to change notification settings - Fork 10
/
gulpfile.js
72 lines (68 loc) · 1.73 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
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 sourcemaps = require('gulp-sourcemaps')
const ts = require('gulp-typescript')
const pack = require('./package.json')
const exportModuleName = 'XEClipboard'
gulp.task('build_commonjs', function () {
return gulp.src(['index.ts'])
// .pipe(sourcemaps.init())
.pipe(ts({
strict: true,
moduleResolution: 'node',
noImplicitAny: true,
target: 'es6',
lib: ['dom', 'es6']
}))
.pipe(babel({
presets: ['@babel/env']
}))
.pipe(rename({
basename: pack.name,
extname: '.common.js'
}))
// .pipe(sourcemaps.write())
.pipe(gulp.dest('dist'))
})
gulp.task('build_umd', function () {
return gulp.src(['index.ts'])
.pipe(ts({
strict: true,
moduleResolution: 'node',
noImplicitAny: true,
target: 'es6',
lib: ['dom', 'es6']
}))
.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_commonjs', 'build_umd'))