-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.mjs
117 lines (102 loc) · 2.71 KB
/
rollup.config.mjs
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
/*
import path from 'path';
import fs from 'fs';
import alias from '@rollup/plugin-alias';
import json from '@rollup/plugin-json';
*/
import commonjs from '@rollup/plugin-commonjs';
import esbuild from 'rollup-plugin-esbuild';
import { dts } from "rollup-plugin-dts";
import resolve from '@rollup/plugin-node-resolve';
import repo from "./package.json" assert { type: 'json' };
const isProduction = process.env.NODE_ENV === 'production';
const esbuildConfig = {
target: 'es2020',
minifySyntax: true,
define: {
'process.env.VERSION': `'${repo.version}'`,
'process.env.DEBUG': isProduction?'false':'true',
},
treeShaking: true,
minify: false,
tsconfigRaw: '{"compilerOptions":{"useDefineForClassFields":false,"experimentalDecorators":true}}',
}
const plugins = [
esbuild(esbuildConfig),
resolve({
browser: true,
preferBuiltins: false,
}),
commonjs(),
/*
json(),
*/
];
const sourcemap = true;//!isProduction;
const freeze=false;
const compiled = (new Date()).toUTCString().replace(/GMT/g, "UTC");
const banner = `/*!
* ${repo.name} - v${repo.version}
* By ${repo.author}
* Compiled ${compiled}
*
* ${repo.name} is licensed under the MIT license.
* http://www.opensource.org/licenses/mit-license
*/`;
const globals={controlwrap:'controlwrap'}
async function main() {
const results=[];
results.push(
{
input: "src/index.ts",
external: Object.keys(repo.peerDependencies),
output: [
{
name: repo.namespace,
banner,
freeze,
sourcemap,
format: "iife",
file: repo.bundle,
globals
},
{
name: repo.namespace,
banner,
freeze,
sourcemap,
format: "esm",
file: repo.module,
globals
}/*,
{
banner,
freeze,
sourcemap,
format: "cjs",
file: repo.main,
globals
}*/
],
plugins
});
//if(isProduction){
results.push(
{
input: "src/index.ts",
external: Object.keys(repo.peerDependencies),
output: [
{
name: repo.namespace,
banner,
file: repo.types,
format: "es",
globals
}
],
plugins:[dts()],
});
//}
return results;
}
export default main();