-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
661 additions
and
588 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 13 additions & 10 deletions
23
packages/vite-node-miniflare/examples/basic/vite.config.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 27 additions & 21 deletions
48
packages/vite-node-miniflare/examples/react-router/vite.config.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,42 @@ | ||
import globRoutesPlugin from "@hiogawa/vite-glob-routes"; | ||
import { vitePluginViteNodeMiniflare } from "@hiogawa/vite-node-miniflare"; | ||
import { vitePluginWorkerd } from "@hiogawa/vite-node-miniflare"; | ||
import react from "@vitejs/plugin-react"; | ||
import { Log } from "miniflare"; | ||
import { defineConfig } from "vite"; | ||
import { vitePluginVirtualIndexHtml } from "../basic/vite.config"; | ||
|
||
export default defineConfig({ | ||
clearScreen: false, | ||
ssr: { | ||
resolve: { | ||
conditions: ["workerd"], | ||
}, | ||
optimizeDeps: { | ||
include: [ | ||
"react", | ||
"react/jsx-dev-runtime", | ||
"react-dom", | ||
"react-dom/server", | ||
], | ||
}, | ||
}, | ||
appType: "custom", | ||
plugins: [ | ||
react(), | ||
globRoutesPlugin({ root: "/src/routes" }), | ||
vitePluginViteNodeMiniflare({ | ||
debug: true, | ||
entry: "/src/server/worker-entry.ts", | ||
miniflareOptions(options) { | ||
options.log = new Log(); | ||
options.compatibilityFlags = ["nodejs_compat"]; | ||
vitePluginWorkerd({ | ||
entry: "/src/server/worker-entry", | ||
miniflare: { | ||
log: new Log(), | ||
compatibilityFlags: ["nodejs_compat"], | ||
}, | ||
}), | ||
react(), | ||
vitePluginVirtualIndexHtml(), | ||
], | ||
environments: { | ||
workerd: { | ||
webCompatible: true, | ||
resolve: { | ||
noExternal: true, | ||
conditions: ["workerd"], | ||
}, | ||
dev: { | ||
optimizeDeps: { | ||
include: [ | ||
"react", | ||
"react/jsx-dev-runtime", | ||
"react-dom", | ||
"react-dom/server", | ||
], | ||
}, | ||
}, | ||
}, | ||
}, | ||
}); |
46 changes: 26 additions & 20 deletions
46
packages/vite-node-miniflare/examples/react/vite.config.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,39 @@ | ||
import { vitePluginViteNodeMiniflare } from "@hiogawa/vite-node-miniflare"; | ||
import { vitePluginWorkerd } from "@hiogawa/vite-node-miniflare"; | ||
import react from "@vitejs/plugin-react"; | ||
import { Log } from "miniflare"; | ||
import { defineConfig } from "vite"; | ||
import { vitePluginVirtualIndexHtml } from "../basic/vite.config"; | ||
|
||
export default defineConfig({ | ||
clearScreen: false, | ||
optimizeDeps: { | ||
// for debugging | ||
// DEBUG=vite:deps pnpm -C examples/react dev | ||
// force: true, | ||
}, | ||
ssr: { | ||
resolve: { | ||
conditions: ["workerd"], | ||
}, | ||
optimizeDeps: { | ||
include: ["react", "react/jsx-dev-runtime", "react-dom/server"], | ||
}, | ||
}, | ||
appType: "custom", | ||
plugins: [ | ||
vitePluginViteNodeMiniflare({ | ||
debug: true, | ||
entry: "/src/worker-entry.tsx", | ||
miniflareOptions(options) { | ||
options.log = new Log(); | ||
react(), | ||
vitePluginWorkerd({ | ||
entry: "/src/worker-entry", | ||
miniflare: { | ||
log: new Log(), | ||
}, | ||
}), | ||
react(), | ||
vitePluginVirtualIndexHtml(), | ||
], | ||
environments: { | ||
workerd: { | ||
webCompatible: true, | ||
resolve: { | ||
noExternal: true, | ||
conditions: ["workerd"], | ||
}, | ||
dev: { | ||
optimizeDeps: { | ||
include: [ | ||
"react", | ||
"react/jsx-runtime", | ||
"react/jsx-dev-runtime", | ||
"react-dom/server", | ||
], | ||
}, | ||
}, | ||
}, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
/build | ||
.mf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
compatibility_date = "2024-01-01" | ||
compatibility_flags = ["nodejs_compat"] | ||
kv_namespaces = [ | ||
{ binding = "kv", id = "test-namespace" } | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.