-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
72 lines (66 loc) · 2.2 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 eslint = require('gulp-eslint')
const prettier = require('gulp-prettier')
const { rollup } = require('rollup')
const terser = require('@rollup/plugin-terser')
const babel = require('@rollup/plugin-babel').default
const commonjs = require('@rollup/plugin-commonjs')
const resolve = require('@rollup/plugin-node-resolve').default
const cache = {}
const babelConfig = {
babelHelpers: 'bundled',
ignore: ['node_modules'],
compact: false,
extensions: ['.js', '.html'],
plugins: ['transform-html-import-to-string'],
presets: [
[
'@babel/preset-env',
{
corejs: 3,
useBuiltIns: 'usage',
modules: false,
},
],
],
configFile: false,
}
gulp.task('lint', () =>
gulp.src(['./**/*.js', '!node_modules/**', '!plugin/awesoMD/awesoMD*.js']).pipe(eslint()).pipe(eslint.format())
)
gulp.task('format', () =>
gulp.src(['./**/*.js', '!node_modules/**', '!plugin/awesoMD/awesoMD*.js']).pipe(prettier()).pipe(gulp.dest('.'))
)
gulp.task('build-plugins', () => {
return Promise.all(
[{ name: 'RevealAwesoMD', input: './plugin/awesoMD/plugin.js', output: './plugin/awesoMD/awesoMD' }].map(
(plugin) => {
return rollup({
cache: cache[plugin.input],
input: plugin.input,
plugins: [
resolve(),
commonjs(),
babel({
...babelConfig,
ignore: ['node_modules'],
}),
terser(),
],
}).then((bundle) => {
cache[plugin.input] = bundle.cache
bundle.write({
file: plugin.output + '.esm.js',
name: plugin.name,
format: 'es',
})
bundle.write({
file: plugin.output + '.js',
name: plugin.name,
format: 'umd',
})
})
}
)
)
})