Repository navigation
Expand file tree
/
Copy pathrollup.config.js
More file actions
163 lines (160 loc) · 3.91 KB
/
Copy pathrollup.config.js
File metadata and controls
163 lines (160 loc) · 3.91 KB
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
import resolve from "@rollup/plugin-node-resolve";
import commonjs from "@rollup/plugin-commonjs";
import typescript from "@rollup/plugin-typescript";
import terser from "@rollup/plugin-terser";
import json from "@rollup/plugin-json";
import { babel } from "@rollup/plugin-babel";
import path from "path";
const getDesktopOutputPath = (filename) => {
const basePath = "D:\\Project\\koodo-reader";
return path.join(basePath, "src", "assets", "lib", filename);
};
const getMobileOutputPath = (filename) => {
const basePath = "D:\\Project\\koodo-reader-expo";
return path.join(basePath, "assets", "lib", filename);
};
export default [
{
input: "src/index.ts",
output: [
{
name: "Kookit",
file: getDesktopOutputPath("kookit.min.js"),
format: "es",
},
],
plugins: [
resolve({ browser: true }),
commonjs({
include: [/node_modules/],
}),
json(),
typescript({ tsconfig: "./tsconfig.json" }),
terser({
format: {
comments: false, // 移除所有注释
},
mangle: false,
}), // 压缩代码
],
external: [
"mammoth",
"jszip",
"underscore",
"marked",
"mhtml2html",
"js-untar",
"fflate",
"rangy/lib/rangy-core.js",
"rangy/lib/rangy-textrange",
"chardet",
],
},
{
input: "src/index.ts",
output: [
{
name: "Kookit",
file: getMobileOutputPath("kookit.min.txt"),
format: "umd",
},
],
plugins: [
resolve({ browser: true }),
commonjs({
include: [/node_modules/],
}),
json(),
typescript({ tsconfig: "./tsconfig.json" }),
babel({
babelHelpers: "bundled",
presets: [
[
"@babel/preset-env",
{
targets: {
browsers: [
"iOS >= 11",
"Android >= 5",
"last 2 versions",
"> 1%",
],
},
useBuiltIns: "usage",
corejs: 3,
},
],
],
exclude: "node_modules/**",
extensions: [".js", ".ts"],
}),
terser({
format: {
comments: false, // 移除所有注释
},
mangle: false,
}), // 压缩代码
],
external: [],
onwarn: (warning, warn) => {
// 忽略循环依赖警告
if (warning.code === "CIRCULAR_DEPENDENCY") {
return;
}
if (warning.code === "EVAL") {
return;
}
warn(warning);
},
},
{
input: "src/mobile.ts",
output: [
{
name: "Kookit",
file: getMobileOutputPath("kookit-mobile.min.js"),
format: "es",
},
],
plugins: [
resolve({ browser: true }),
commonjs({
include: [/node_modules/],
ignoreGlobal: true,
}),
json(),
typescript({ tsconfig: "./tsconfig.json" }),
terser({
format: {
comments: false, // 移除所有注释
},
mangle: false,
}), // 压缩代码
],
external: [],
onwarn: (warning, warn) => {
// 忽略循环依赖警告
if (warning.code === "CIRCULAR_DEPENDENCY") {
return;
}
if (warning.code === "EVAL") {
return;
}
warn(warning);
},
},
// CommonJS (for Node) and ES module (for bundlers) build.
// (We could have three entries in the configuration array
// instead of two, but it's quicker to generate multiple
// builds from a single configuration where possible, using
// an array for the `output` option, where we can specify
// `file` and `format` for each target)
// {
// input: "src/index.ts",
// output: [
// { file: pkg.main, format: "cjs" },
// { file: pkg.module, format: "es" },
// ],
// plugins: [typescript({ tsconfig: "./tsconfig.json" })],
// },
];