mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-16 04:27:21 +00:00
Refactor Vite integration and update docs
Introduced a Vite adapter with "fresh" and "cached" modes, centralized dev server configuration, and streamlined the example setup. Updated documentation with detailed steps for Vite integration and revised the internal dev environment to align with the changes.
This commit is contained in:
@@ -1,48 +1,29 @@
|
||||
import devServer from "@hono/vite-dev-server";
|
||||
import react from "@vitejs/plugin-react";
|
||||
import { defineConfig, loadEnv } from "vite";
|
||||
import { defineConfig } from "vite";
|
||||
import tsconfigPaths from "vite-tsconfig-paths";
|
||||
import { devServerConfig } from "./src/adapter/vite/dev-server-config";
|
||||
|
||||
// https://vitejs.dev/config/
|
||||
export default defineConfig(async () => {
|
||||
/**
|
||||
* DEVELOPMENT MODE
|
||||
*/
|
||||
if (process.env.NODE_ENV === "development") {
|
||||
return {
|
||||
define: {
|
||||
__isDev: "1"
|
||||
},
|
||||
clearScreen: false,
|
||||
publicDir: "./src/admin/assets",
|
||||
server: {
|
||||
host: true,
|
||||
port: 28623,
|
||||
hmr: {
|
||||
overlay: true
|
||||
}
|
||||
},
|
||||
plugins: [
|
||||
react(),
|
||||
tsconfigPaths(),
|
||||
devServer({
|
||||
entry: "./vite.dev.ts",
|
||||
exclude: [
|
||||
// We need to override this option since the default setting doesn't fit
|
||||
/.*\.tsx?($|\?)/,
|
||||
/^(?!.*\/__admin).*\.(s?css|less)($|\?)/,
|
||||
/^(?!.*\/api).*\.(svg|png)($|\?)/, // exclude except /api
|
||||
/^\/@.+$/,
|
||||
/^\/favicon\.ico$/,
|
||||
/^\/(public|assets|static)\/.+/,
|
||||
/^\/node_modules\/.*/
|
||||
],
|
||||
//injectClientScript: true
|
||||
injectClientScript: false // This option is buggy, disable it and inject the code manually
|
||||
})
|
||||
]
|
||||
};
|
||||
}
|
||||
|
||||
throw new Error("Don't use vite for building in production");
|
||||
export default defineConfig({
|
||||
define: {
|
||||
__isDev: "1"
|
||||
},
|
||||
clearScreen: false,
|
||||
publicDir: "./src/admin/assets",
|
||||
server: {
|
||||
host: true,
|
||||
port: 28623,
|
||||
hmr: {
|
||||
overlay: true
|
||||
}
|
||||
},
|
||||
plugins: [
|
||||
react(),
|
||||
tsconfigPaths(),
|
||||
devServer({
|
||||
...devServerConfig,
|
||||
entry: "./vite.dev.ts"
|
||||
})
|
||||
]
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user