-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathrslib.config.ts
84 lines (78 loc) · 2.1 KB
/
rslib.config.ts
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
import fs from "fs";
import path from "path";
import { defineConfig } from "@rslib/core";
import { pluginNodePolyfill } from "@rsbuild/plugin-node-polyfill";
import { pluginStylus } from "@rsbuild/plugin-stylus";
import { RsdoctorRspackPlugin } from "@rsdoctor/rspack-plugin";
import { NodeEnvType } from "./src/types/env";
import isProductionMode from "./src/util/isProductionMode";
const rootDir = fs.realpathSync(process.cwd());
const resolvePath = (relativePath: string) => path.resolve(rootDir, relativePath);
const srcDir = resolvePath("src");
const tsConfigProd = resolvePath("tsconfig.prod.json");
const tsEntry = resolvePath(path.join(srcDir, "index.ts"));
export default defineConfig({
lib: [
{
format: "esm",
syntax: "es2022",
dts: true,
output: {
distPath: {
root: "./dist/esm/",
},
},
},
{
format: "cjs",
// This will include all the JS code into one single file without
// the use of require()
autoExternal: false,
syntax: "es2015",
output: {
distPath: {
root: "./dist/cjs/",
},
},
},
{
format: "umd",
// This will include all the JS code into one single file without
// the use of require()
autoExternal: false,
umdName: "VideomailClient",
output: {
distPath: {
root: "./dist/umd/",
},
},
},
],
mode: isProductionMode() ? NodeEnvType.PRODUCTION : NodeEnvType.DEVELOPMENT,
output: {
target: "web",
injectStyles: true,
legalComments: "none",
},
source: {
entry: {
index: tsEntry,
},
tsconfigPath: tsConfigProd,
},
plugins: [pluginStylus(), pluginNodePolyfill()],
tools: {
htmlPlugin: false,
rspack: (_config, { appendPlugins }) => {
// Only register the plugin when RSDOCTOR is true, as the plugin will increase the build time
// Can be run with RSDOCTOR=true npm run build:prod
if (process.env.RSDOCTOR) {
appendPlugins(
new RsdoctorRspackPlugin({
// plugin options
}),
);
}
},
},
});