feat: update Vite configuration for improved HMR support and module resolution
This commit is contained in:
parent
538c081d58
commit
cf7ce088f8
@ -4,6 +4,13 @@ import tailwindcss from "@tailwindcss/vite";
|
|||||||
import react from "@vitejs/plugin-react";
|
import react from "@vitejs/plugin-react";
|
||||||
import { defineConfig } from "vite";
|
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/
|
// https://vite.dev/config/
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
build: {
|
build: {
|
||||||
@ -13,10 +20,26 @@ export default defineConfig({
|
|||||||
"process.env": {},
|
"process.env": {},
|
||||||
},
|
},
|
||||||
plugins: [react(), tailwindcss()],
|
plugins: [react(), tailwindcss()],
|
||||||
|
server: {
|
||||||
|
host: true,
|
||||||
|
hmr:
|
||||||
|
hmrHost || hmrClientPort || hmrProtocol
|
||||||
|
? {
|
||||||
|
host: hmrHost,
|
||||||
|
clientPort: hmrClientPort,
|
||||||
|
protocol: hmrProtocol,
|
||||||
|
}
|
||||||
|
: undefined,
|
||||||
|
},
|
||||||
resolve: {
|
resolve: {
|
||||||
dedupe: ["react", "react-dom"],
|
dedupe: ["react", "react-dom", "react/jsx-runtime", "react/jsx-dev-runtime"],
|
||||||
alias: {
|
alias: {
|
||||||
"@": path.resolve(__dirname, "./src"),
|
"@": 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"),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user