forked from laobubu/HyperMD
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
64 lines (55 loc) · 1.43 KB
/
rollup.config.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
import buble from 'rollup-plugin-buble'
import typescript from 'rollup-plugin-typescript2'
import { uglify } from 'rollup-plugin-uglify'
const { banner, globalNames, externalNames, bundleFiles } = require(__dirname + '/dev/HyperMD.config')
const plugins = {
ts: typescript({
tsconfigOverride: {
compilerOptions: {
"target": "es6",
"module": "es6",
"declaration": false,
}
}
}),
uglify: uglify({
output: {
comments: /^!/,
},
}),
buble: buble({
namedFunctionExpressions: false,
transforms: {
dangerousForOf: true, // simplify `for (let i=0;i...)` to `for (let it of arr)`
}
}),
}
var configs = []
function isExternal(mod) {
if (/\.css$/.test(mod)) return true
for (const modBase of externalNames) {
if (mod.substr(0, modBase.length) === modBase) return true
}
return false
}
bundleFiles.forEach(item => {
var item_plugins = [plugins.ts] // Essential: typescript
if (item.uglify) item_plugins.push(plugins.uglify) // optional: uglify
item_plugins.push(plugins.buble) // Essential: Buble
var _banner = banner
if (item.banner) _banner += "\n" + item.banner
var out = {
input: "./" + item.entry,
external: isExternal,
output: {
file: './' + item.output,
format: 'umd',
name: item.name,
globals: globalNames,
banner: _banner,
},
plugins: item_plugins
}
configs.push(out)
})
export default configs