-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
84 lines (71 loc) · 1.83 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/**
* Created by nullice on 2017/4/5.
*/
const PACKAGE_JSON = require("./package.json")
const PACKAGE_NAME = PACKAGE_JSON.fullName
const ENTRY = "./src/index.ts"
import babel from "rollup-plugin-babel"
import typescript from "rollup-plugin-typescript2"
import resolve from "rollup-plugin-node-resolve"
import commonjs from "rollup-plugin-commonjs"
import {uglify} from "rollup-plugin-uglify"
import copy from "rollup-plugin-cpy"
function genConfig(format = "umd", useUglify)
{
let bableConfig = {exclude: "node_modules/**",}
if (format == "cjs")
{
bableConfig.presets = [
[
"@babel/preset-env",
{
"targets": {
"node": "6.10"
},
"modules": false
}
]
]
}
let config = {
input: ENTRY,
output: {
file: `./dist/${PACKAGE_NAME}.${format}.js`,
format: `${format}`,
name: PACKAGE_NAME,
},
plugins: [
typescript({
typescript: require("typescript"),
cacheRoot: "./temp/cache_rollup-plugin-typescript2",
useTsconfigDeclarationDir: true,
tsconfigOverride: {
compilerOptions: {
module: "es2015",
},
},
}),
babel(bableConfig),
resolve(),
commonjs(),
],
}
if (format == "umd")
{
}
if (format == "cjs")
{
}
if (useUglify)
{
config.plugins.push(uglify())
config.output.file = `./dist/${PACKAGE_NAME}.${format}.min.js`
}
return config
}
export default [
genConfig("umd"),
genConfig("umd", true),
genConfig("es"),
genConfig("cjs"),
]