2024-08-20 13:57:59 +00:00
|
|
|
import { defineConfig } from "vite";
|
2024-08-21 15:14:40 +00:00
|
|
|
import { resolve } from "path";
|
|
|
|
import dts from "vite-plugin-dts";
|
|
|
|
import react from "@vitejs/plugin-react";
|
|
|
|
import { libInjectCss } from "vite-plugin-lib-inject-css";
|
|
|
|
import { extname, relative } from "path";
|
|
|
|
import { fileURLToPath } from "node:url";
|
2024-09-30 10:45:06 +00:00
|
|
|
import { globSync } from "glob";
|
2024-11-06 18:46:29 +00:00
|
|
|
import svgr from "vite-plugin-svgr";
|
2024-08-20 13:57:59 +00:00
|
|
|
|
|
|
|
// https://vitejs.dev/config/
|
|
|
|
export default defineConfig({
|
|
|
|
worker: {
|
2024-08-20 14:10:02 +00:00
|
|
|
rollupOptions: {
|
2024-09-30 10:45:06 +00:00
|
|
|
external: ["@codex-storage/sdk-js"],
|
2024-08-21 15:14:40 +00:00
|
|
|
output: {
|
|
|
|
globals: {
|
2024-08-30 14:10:17 +00:00
|
|
|
"@codex-storage/sdk-js": "codex-sdk-js",
|
2024-08-21 15:14:40 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
plugins: [
|
|
|
|
react(),
|
|
|
|
libInjectCss(),
|
|
|
|
dts({
|
|
|
|
tsconfigPath: "./tsconfig.build.json",
|
|
|
|
rollupTypes: true,
|
|
|
|
}),
|
2024-11-06 18:46:29 +00:00
|
|
|
svgr({
|
|
|
|
svgrOptions: {
|
|
|
|
plugins: ["@svgr/plugin-svgo", "@svgr/plugin-jsx"],
|
|
|
|
svgoConfig: {
|
|
|
|
floatPrecision: 2,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
// ...
|
|
|
|
})
|
2024-08-21 15:14:40 +00:00
|
|
|
],
|
|
|
|
build: {
|
|
|
|
lib: {
|
|
|
|
entry: resolve(__dirname, "src/index.ts"),
|
|
|
|
formats: ["es"],
|
|
|
|
},
|
2024-08-30 14:36:06 +00:00
|
|
|
sourcemap: true,
|
2024-08-21 15:14:40 +00:00
|
|
|
rollupOptions: {
|
|
|
|
external: [
|
|
|
|
"react",
|
|
|
|
"react/jsx-runtime",
|
2024-08-30 14:10:17 +00:00
|
|
|
"@codex-storage/sdk-js",
|
2024-08-21 15:14:40 +00:00
|
|
|
],
|
|
|
|
input: Object.fromEntries(
|
2024-09-30 10:45:06 +00:00
|
|
|
globSync("src/**/*.{ts,tsx}", {
|
|
|
|
ignore: ["src/**/*.d.ts"],
|
|
|
|
})
|
2024-08-21 15:14:40 +00:00
|
|
|
.map((file) => [
|
|
|
|
// The name of the entry point
|
|
|
|
// lib/nested/foo.ts becomes nested/foo
|
|
|
|
relative("src", file.slice(0, file.length - extname(file).length)),
|
|
|
|
// The absolute path to the entry file
|
|
|
|
// lib/nested/foo.ts becomes /project/lib/nested/foo.ts
|
|
|
|
fileURLToPath(new URL(file, import.meta.url)),
|
|
|
|
])
|
|
|
|
),
|
|
|
|
output: {
|
|
|
|
assetFileNames: "assets/[name][extname]",
|
|
|
|
entryFileNames: "[name].js",
|
|
|
|
globals: {
|
2024-08-30 14:10:17 +00:00
|
|
|
"@codex-storage/sdk-js": "codex-sdk-js",
|
2024-08-21 15:14:40 +00:00
|
|
|
},
|
|
|
|
},
|
2024-08-20 14:10:02 +00:00
|
|
|
},
|
2024-08-20 13:57:59 +00:00
|
|
|
},
|
|
|
|
});
|