Comparing version 0.1.22 to 0.1.23
import { Plugin } from 'vite'; | ||
type Options = { | ||
type ClientOptions = { | ||
jsxImportSource?: string; | ||
assetsDir?: string; | ||
input?: string[]; | ||
}; | ||
declare const defaultOptions: Options; | ||
declare function client(options?: Options): Plugin; | ||
declare const defaultOptions: ClientOptions; | ||
declare function client(options?: ClientOptions): Plugin; | ||
export { client as default, defaultOptions }; | ||
export { type ClientOptions, client as default, defaultOptions }; |
const defaultOptions = { | ||
jsxImportSource: "hono/jsx/dom", | ||
assetsDir: "static" | ||
assetsDir: "static", | ||
input: [] | ||
}; | ||
@@ -8,7 +9,14 @@ function client(options) { | ||
name: "honox-vite-client", | ||
apply: (_config, { command, mode }) => { | ||
if (command === "build" && mode === "client") { | ||
return true; | ||
} | ||
return false; | ||
}, | ||
config: () => { | ||
const input = options?.input ?? defaultOptions.input ?? []; | ||
return { | ||
build: { | ||
rollupOptions: { | ||
input: ["/app/client.ts"] | ||
input: ["/app/client.ts", ...input] | ||
}, | ||
@@ -15,0 +23,0 @@ assetsDir: options?.assetsDir ?? defaultOptions.assetsDir, |
@@ -6,2 +6,3 @@ import { DevServerOptions } from '@hono/vite-dev-server'; | ||
export { islandComponents } from './island-components.js'; | ||
import { ClientOptions } from './client.js'; | ||
@@ -13,2 +14,3 @@ type Options = { | ||
islandComponents?: IslandComponentsOptions; | ||
client?: ClientOptions; | ||
external?: string[]; | ||
@@ -15,0 +17,0 @@ }; |
@@ -6,2 +6,3 @@ import path from "path"; | ||
import { restartOnAddUnlink } from "./restart-on-add-unlink.js"; | ||
import client from "./client.js"; | ||
const defaultOptions = { | ||
@@ -31,2 +32,3 @@ islands: true, | ||
plugins.push(restartOnAddUnlink()); | ||
plugins.push(client(options?.client)); | ||
return [ | ||
@@ -33,0 +35,0 @@ { |
{ | ||
"name": "honox", | ||
"version": "0.1.22", | ||
"version": "0.1.23", | ||
"main": "dist/index.js", | ||
@@ -5,0 +5,0 @@ "type": "module", |
@@ -96,2 +96,3 @@ # HonoX | ||
```tsx | ||
// app/routes/index.tsx | ||
// `createRoute()` helps you create handlers | ||
@@ -112,2 +113,3 @@ import { createRoute } from 'honox/factory' | ||
```tsx | ||
// app/routes/index.tsx | ||
import { createRoute } from 'honox/factory' | ||
@@ -162,2 +164,3 @@ import { getCookie, setCookie } from 'hono/cookie' | ||
```tsx | ||
// app/routes/index.tsx | ||
export default function Home(_c: Context) { | ||
@@ -666,17 +669,13 @@ return <h1>Welcome!</h1> | ||
import { defineConfig } from 'vite' | ||
import pages from '@hono/vite-cloudflare-pages' | ||
export default defineConfig(({ mode }) => { | ||
if (mode === 'client') { | ||
return { | ||
build: { | ||
rollupOptions: { | ||
input: ['/app/style.css'], | ||
}, | ||
export default defineConfig({ | ||
plugins: [ | ||
honox({ | ||
client: { | ||
input: ['/app/style.css'], | ||
}, | ||
} | ||
} else { | ||
return { | ||
plugins: [honox()], | ||
} | ||
} | ||
}), | ||
pages(), | ||
], | ||
}) | ||
@@ -697,4 +696,2 @@ ``` | ||
const entry = './app/server.ts' | ||
export default defineConfig(() => { | ||
@@ -704,3 +701,2 @@ return { | ||
honox(), | ||
devServer({ entry }), | ||
mdx({ | ||
@@ -809,24 +805,2 @@ jsxImportSource: 'hono/jsx', | ||
If you want to include client-side scripts and assets: | ||
```ts | ||
// vite.config.ts | ||
import pages from '@hono/vite-cloudflare-pages' | ||
import honox from 'honox/vite' | ||
import client from 'honox/vite/client' | ||
import { defineConfig } from 'vite' | ||
export default defineConfig(({ mode }) => { | ||
if (mode === 'client') { | ||
return { | ||
plugins: [client()], | ||
} | ||
} else { | ||
return { | ||
plugins: [honox(), pages()], | ||
} | ||
} | ||
}) | ||
``` | ||
Build command (including a client): | ||
@@ -833,0 +807,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2080
98100
884