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
| // scripts/build.ts
import { build } from "vite";
import { dirname, resolve } from "path";
import { fileURLToPath } from "url";
import terser from "@rollup/plugin-terser";
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
export const r = (...args: string[]) =>
resolve(__dirname, "..", ...args).replace(/\\/g, "/");
// 在这里定义你需要打包的模块
const files = ["A.ts", "B.ts", "C.ts"];
for (let fileName of files) {
const filePath = r(`src/${fileName}`);
const name = fileName.split(".")[0];
build({
root: r("src"),
build: {
outDir: r("dist"),
emptyOutDir: false,
sourcemap: false,
cssCodeSplit: false,
lib: {
entry: filePath,
name: name,
formats: ["es"],
},
rollupOptions: {
output: {
entryFileNames: `${name}.js`,
},
plugins: [terser()],
},
},
});
}
|