-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.js
47 lines (41 loc) · 1014 Bytes
/
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
const gulp = require('gulp')
const rename = require('gulp-rename')
const rollup = require('gulp-better-rollup')
const babel = require('rollup-plugin-babel')
const resolve = require('rollup-plugin-node-resolve')
const commonjs = require('rollup-plugin-commonjs')
const external = id => !id.startsWith('src') && !id.startsWith('.') && !id.startsWith('/') && !id.startsWith('\0')
const babelConfig = {
presets: [
['@babel/preset-env', {
modules: false,
targets: {
node: '8.0.0'
}
}]
],
comments: false,
exclude: 'node_modules/**'
}
gulp.task('cjs', () =>
gulp.src('src/index.js')
.pipe(rollup({
external,
plugins: [resolve(), commonjs(), babel(babelConfig)]
}, {
format: 'cjs'
}))
.pipe(gulp.dest('.'))
)
gulp.task('es6', () =>
gulp.src('src/index.js')
.pipe(rollup({
external,
plugins: [resolve(), commonjs(), babel(babelConfig)]
}, {
format: 'es'
}))
.pipe(rename('index.mjs'))
.pipe(gulp.dest('.'))
)
gulp.task('default', gulp.series('cjs', 'es6'))