2023-05-04 15:04:47 +02:00
|
|
|
import { resolve } from "path";
|
2023-11-22 17:29:53 +01:00
|
|
|
import { defineConfig, BuildOptions } from "vite";
|
2022-12-01 12:05:08 +01:00
|
|
|
import react from "@vitejs/plugin-react";
|
|
|
|
|
import dts from "vite-plugin-dts";
|
2023-01-04 15:52:24 +01:00
|
|
|
import tsconfigPaths from "vite-tsconfig-paths";
|
2022-12-01 12:05:08 +01:00
|
|
|
|
|
|
|
|
// https://vitejs.dev/config/
|
2023-08-11 15:15:12 +02:00
|
|
|
export default defineConfig(({ mode }) => {
|
|
|
|
|
let buildOptions: { watch: BuildOptions["watch"] };
|
|
|
|
|
let emptyOutDir = true;
|
|
|
|
|
if (mode.includes("watch")) {
|
|
|
|
|
emptyOutDir = false;
|
|
|
|
|
buildOptions = {
|
|
|
|
|
watch: {
|
|
|
|
|
include: ["src/**/*"],
|
2022-12-01 12:05:08 +01:00
|
|
|
},
|
2023-08-11 15:15:12 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (mode.includes("polling")) {
|
|
|
|
|
buildOptions = {
|
|
|
|
|
watch: {
|
|
|
|
|
...buildOptions.watch,
|
|
|
|
|
chokidar: {
|
|
|
|
|
usePolling: true,
|
|
|
|
|
interval: 1000,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
build: {
|
|
|
|
|
emptyOutDir,
|
|
|
|
|
outDir: "dist",
|
|
|
|
|
sourcemap: true,
|
|
|
|
|
lib: {
|
|
|
|
|
entry: {
|
|
|
|
|
index: "./src/index.ts",
|
2022-12-01 12:05:08 +01:00
|
|
|
},
|
2023-08-11 15:15:12 +02:00
|
|
|
formats: ["es", "cjs"],
|
2025-01-07 17:45:12 +01:00
|
|
|
cssFileName: 'style'
|
2022-12-01 12:05:08 +01:00
|
|
|
},
|
2023-08-11 15:15:12 +02:00
|
|
|
rollupOptions: {
|
|
|
|
|
external: ["react", "react-dom"],
|
|
|
|
|
output: {
|
|
|
|
|
globals: {
|
|
|
|
|
react: "React",
|
|
|
|
|
"react-dom": "ReactDOM",
|
|
|
|
|
},
|
|
|
|
|
},
|
2023-05-04 15:07:04 +02:00
|
|
|
},
|
2024-03-25 15:59:02 +01:00
|
|
|
copyPublicDir: false,
|
2023-08-11 15:15:12 +02:00
|
|
|
...buildOptions,
|
2023-01-04 15:52:24 +01:00
|
|
|
},
|
2023-08-11 15:15:12 +02:00
|
|
|
plugins: [
|
|
|
|
|
tsconfigPaths(),
|
|
|
|
|
dts({
|
|
|
|
|
rollupTypes: true,
|
|
|
|
|
beforeWriteFile: (filePath, content) => {
|
|
|
|
|
return {
|
|
|
|
|
filePath,
|
|
|
|
|
content: content.replace("../../locales", "./locales"),
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
}),
|
|
|
|
|
react(),
|
2023-05-04 15:04:47 +02:00
|
|
|
],
|
2023-08-11 15:15:12 +02:00
|
|
|
test: {
|
|
|
|
|
environment: "jsdom",
|
|
|
|
|
reporters: "verbose",
|
|
|
|
|
globals: true,
|
|
|
|
|
watchExclude: ["**/cunningham-tokens.js"],
|
|
|
|
|
coverage: {
|
|
|
|
|
all: true,
|
|
|
|
|
include: ["src/**/*.{ts,tsx}"],
|
|
|
|
|
exclude: ["**/*.stories.tsx", "**/*.spec.tsx"],
|
|
|
|
|
},
|
|
|
|
|
globalSetup: ["src/tests/Global.ts"],
|
|
|
|
|
setupFiles: ["src/tests/Setup.ts"],
|
|
|
|
|
},
|
|
|
|
|
resolve: {
|
|
|
|
|
alias: [
|
|
|
|
|
{
|
|
|
|
|
find: ":",
|
|
|
|
|
replacement: resolve(__dirname, "./src"),
|
|
|
|
|
},
|
2025-01-07 17:45:12 +01:00
|
|
|
{
|
|
|
|
|
find: "src",
|
|
|
|
|
replacement: resolve(__dirname, "./src"),
|
|
|
|
|
}
|
2023-08-11 15:15:12 +02:00
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
};
|
2022-12-01 12:05:08 +01:00
|
|
|
});
|