uikit/vite.config.js
Mohamadzadeh 414a95a3bb
All checks were successful
Build and Deploy Next.js + Nginx Docker Image / build-and-deploy (push) Successful in 50s
Build and Deploy Next.js + Nginx Docker Image / deploy (push) Successful in 7s
fix
2026-07-13 15:03:25 +03:30

114 lines
2.3 KiB
JavaScript

import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import path from "path";
const externalPackages = [
"react",
"react-dom",
"react-dom/client",
"react-dom/server",
"react/jsx-runtime",
"@chakra-ui/react",
"@emotion/react",
"@emotion/styled",
"framer-motion",
"keycloak-js",
"axios",
"@tanstack/react-query",
"@tanstack/react-table",
"react-icons",
"react-hook-form",
"react-select",
"chakra-react-select",
];
export default defineConfig(({ mode }) => {
if (mode === "remote") {
return {
plugins: [react()],
define: {
"process.env.NODE_ENV": JSON.stringify("production"),
},
build: {
outDir: "dist",
emptyOutDir: false,
target: "es2020",
lib: {
entry: path.resolve(process.cwd(), "src/remote/ui/GBadge.remote.jsx"),
formats: ["es"],
},
rollupOptions: {
treeshake: true,
output: {
entryFileNames: "remote/GBadge.js",
inlineDynamicImports: true,
},
},
},
};
}
return {
plugins: [react()],
build: {
lib: {
entry: {
index: path.resolve(process.cwd(), "src/index.js"),
utils: path.resolve(process.cwd(), "src/utils/index.js"),
pagination: path.resolve(process.cwd(), "src/pagination/index.js"),
layout: path.resolve(process.cwd(), "src/layout/index.js"),
core: path.resolve(process.cwd(), "src/core/index.js"),
table: path.resolve(process.cwd(), "src/table/index.js"),
form: path.resolve(process.cwd(), "src/form/index.js"),
icons: path.resolve(process.cwd(), "src/icons/index.js"),
"remote-ui": path.resolve(process.cwd(), "src/remote/ui/index.jsx"),
},
formats: ["es"],
},
rollupOptions: {
external: (id) => {
return (
externalPackages.includes(id) ||
id.startsWith("react-icons/") ||
id.startsWith("@emotion/") ||
id.startsWith("react-select/")
);
},
output: {
entryFileNames: "[name].js",
chunkFileNames: "chunks/[name]-[hash].js",
assetFileNames: "assets/[name]-[hash][extname]",
},
},
},
};
});