-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
125 lines (112 loc) · 3.07 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
import { createRequire } from "module";
import commonjs from "@rollup/plugin-commonjs";
import nodeResolve from "@rollup/plugin-node-resolve";
import sourcemaps from "rollup-plugin-sourcemaps";
import terser from '@rollup/plugin-terser';
const require = createRequire(import.meta.url);
const pkg = require("./package.json");
let debug = false;
const browserTplIndex = (input, umdOutput, esOutput) => ({
input: input,
external: id => {
console.log(id);
return id.indexOf("./") >= 0;
},
output: [{
file: umdOutput + ".js",
format: "umd",
sourcemap: true,
name: pkg.name,
minifyInternalExports:false
}, {
file: esOutput + ".js",
format: "es",
sourcemap: true,
minifyInternalExports:false
}],
plugins: [
nodeResolve({
preferBuiltins: true
}),
commonjs({}),
sourcemaps(),
debug ? undefined : terser({})
]
});
const browserTpl = (input, umdOutput, esOutput) => ({
input: input,
output: [{
file: umdOutput + ".js",
format: "umd",
sourcemap: true,
name: pkg.name,
minifyInternalExports:false
}, {
file: esOutput + ".js",
format: "es",
sourcemap: true,
minifyInternalExports:false
}],
plugins: [
nodeResolve({
preferBuiltins: true
}),
commonjs({}),
sourcemaps(),
debug ? undefined : terser({})
]
});
const nodeTpl = (input, cjsOutput, esOutput) => ({
input: input,
output: [{
file: cjsOutput + ".cjs",
format: "cjs",
sourcemap: true,
name: pkg.name,
manualChunks: () => "__hack_for_single_file_.js",
minifyInternalExports:false
}, {
file: esOutput + ".js",
format: "es",
sourcemap: true,
manualChunks: () => "__hack_for_single_file_.js",
minifyInternalExports:false
}],
plugins: [
nodeResolve({
preferBuiltins: true
}),
commonjs({}),
sourcemaps(),
debug ? undefined : terser({})
]
});
const binTpl = (input, esOutput) => ({
input,
external: id => {
if (id.indexOf("./") !== 0 && id.indexOf("__bin__") < 0) {
return true;
}
return false;
},
output: [{
file: esOutput,
format: "es",
sourcemap: true,
name: pkg.name,
minifyInternalExports:false
}],
plugins: [
sourcemaps()
]
});
export default args => {
debug = args.configDebug ?? false;
return [
browserTplIndex("lib-esm/index", "dist/index.umd", "dist/index"),
browserTpl("lib-esm/webdggrid", "dist/webdggrid.umd", "dist/webdggrid"),
// browserTpl("lib-esm/__tests__/index-browser", "dist-test/index.umd", "dist-test/index"),
// browserTpl("lib-esm/__tests__/worker-browser", "dist-test/worker.umd", "dist-test/worker"),
// nodeTpl("lib-esm/__tests__/worker-node", "dist-test/worker.node", "dist-test/worker.node"),
];
};