forked from microsoft/typespec
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.ts
57 lines (56 loc) · 1.54 KB
/
rollup.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
import commonjs from "@rollup/plugin-commonjs";
import typescript from "@rollup/plugin-typescript";
import { readFileSync } from "fs";
import { dirname, resolve } from "path";
import { defineConfig } from "rollup";
// To handle css files
import postcss from "rollup-plugin-postcss";
import { fileURLToPath } from "url";
const __dirname = dirname(fileURLToPath(import.meta.url));
const packageJson = JSON.parse(readFileSync(resolve(__dirname, "package.json")).toString());
const dependencies = Object.keys(packageJson.dependencies);
const external = [
...dependencies,
"swagger-ui-dist/swagger-ui-es-bundle.js",
"swagger-ui-dist/swagger-ui.css",
"@typespec/bundler/vite",
"react-dom/client",
"react/jsx-runtime",
"vite",
"@vitejs/plugin-react",
"fs/promises",
];
export default defineConfig([
{
input: {
index: "src/index.ts",
"react/index": "src/react/index.ts",
"react/viewers/index": "src/react/viewers/index.tsx",
"tooling/index": "src/tooling/index.ts",
"vite/index": "src/vite/index.ts",
},
treeshake: false,
output: {
dir: "dist",
format: "esm",
sourcemap: true,
// preserveModules: true,
// preserveModulesRoot: ".",
exports: "named",
},
plugins: [
(commonjs as any)(),
(typescript as any)({
tsconfig: "./tsconfig.build.json",
declaration: true,
declarationDir: "./dist",
sourceMap: true,
inlineSources: true,
}),
(postcss as any)({
extract: true,
}),
],
external,
},
]);