-
Notifications
You must be signed in to change notification settings - Fork 29
/
index.ts
63 lines (53 loc) · 1.41 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import path from 'path'
import devServer, { defaultOptions as devServerDefaultOptions } from '@hono/vite-dev-server'
import type { DevServerOptions } from '@hono/vite-dev-server'
import type { PluginOption } from 'vite'
import { injectImportingIslands } from './inject-importing-islands.js'
import { islandComponents } from './island-components.js'
import { restartOnAddUnlink } from './restart-on-add-unlink.js'
type Options = {
islands?: boolean
entry?: string
devServer?: DevServerOptions
external?: string[]
}
export const defaultOptions: Options = {
islands: true,
entry: path.join(process.cwd(), './app/server.ts'),
}
function honox(options?: Options): PluginOption[] {
const plugins: PluginOption[] = []
const entry = options?.entry ?? defaultOptions.entry
plugins.push(
devServer({
entry,
exclude: [
...devServerDefaultOptions.exclude,
/^\/app\/.+/,
/^\/favicon.ico/,
/^\/static\/.+/,
],
...options?.devServer,
})
)
if (options?.islands !== false) {
plugins.push(islandComponents())
}
plugins.push(injectImportingIslands())
plugins.push(restartOnAddUnlink())
return [
{
name: 'honox-vite-config',
config: () => {
return {
ssr: {
noExternal: true,
},
}
},
},
...plugins,
]
}
export { devServerDefaultOptions, islandComponents }
export default honox