1 Star 0 Fork 16

wiszsw/xe-clipboard

forked from XE/xe-clipboard 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
gulpfile.js 1.72 KB
一键复制 编辑 原始数据 按行查看 历史
xuliangzhan 提交于 2020-09-10 12:32 . update
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'))
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/wiszsw/xe-clipboard.git
git@gitee.com:wiszsw/xe-clipboard.git
wiszsw
xe-clipboard
xe-clipboard
master

搜索帮助