46 lines
1.4 KiB
TypeScript
46 lines
1.4 KiB
TypeScript
import path from "node:path";
|
|
|
|
import tailwindcss from "@tailwindcss/vite";
|
|
import react from "@vitejs/plugin-react";
|
|
import { defineConfig } from "vite";
|
|
|
|
const appNodeModulesPath = path.resolve(__dirname, "./node_modules");
|
|
const hmrHost = process.env.VITE_HMR_HOST;
|
|
const hmrClientPort = process.env.VITE_HMR_CLIENT_PORT
|
|
? Number(process.env.VITE_HMR_CLIENT_PORT)
|
|
: undefined;
|
|
const hmrProtocol = process.env.VITE_HMR_PROTOCOL;
|
|
|
|
// https://vite.dev/config/
|
|
export default defineConfig({
|
|
build: {
|
|
sourcemap: true,
|
|
},
|
|
define: {
|
|
"process.env": {},
|
|
},
|
|
plugins: [react(), tailwindcss()],
|
|
server: {
|
|
host: true,
|
|
hmr:
|
|
hmrHost || hmrClientPort || hmrProtocol
|
|
? {
|
|
host: hmrHost,
|
|
clientPort: hmrClientPort,
|
|
protocol: hmrProtocol,
|
|
}
|
|
: undefined,
|
|
},
|
|
resolve: {
|
|
dedupe: ["react", "react-dom", "react/jsx-runtime", "react/jsx-dev-runtime"],
|
|
alias: {
|
|
"@": path.resolve(__dirname, "./src"),
|
|
react: path.resolve(appNodeModulesPath, "react"),
|
|
"react-dom": path.resolve(appNodeModulesPath, "react-dom"),
|
|
"react-dom/client": path.resolve(appNodeModulesPath, "react-dom/client.js"),
|
|
"react/jsx-runtime": path.resolve(appNodeModulesPath, "react/jsx-runtime.js"),
|
|
"react/jsx-dev-runtime": path.resolve(appNodeModulesPath, "react/jsx-dev-runtime.js"),
|
|
},
|
|
},
|
|
});
|