Skip to content

Commit 1a6b277

Browse files
authored
feat(ssg): expose extensionMap to ssg build (#304)
1 parent 286cdff commit 1a6b277

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

.changeset/large-planets-rescue.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@hono/vite-ssg': minor
3+
---
4+
5+
add ssg build option to specify extensionMap

packages/ssg/src/ssg.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { Hono } from 'hono'
2-
import { toSSG } from 'hono/ssg'
2+
import { toSSG, defaultExtensionMap } from 'hono/ssg'
33
import type { SSGPlugin } from 'hono/ssg'
44
import type { Plugin, ResolvedConfig } from 'vite'
55
import { createServer } from 'vite'
@@ -13,11 +13,13 @@ type SSGOptions = {
1313
* @see https://hono.dev/docs/helpers/ssg#plugins
1414
*/
1515
plugins?: SSGPlugin[]
16+
extensionMap?: Record<string, string>
1617
}
1718

1819
export const defaultOptions: Required<SSGOptions> = {
1920
entry: './src/index.tsx',
2021
plugins: [],
22+
extensionMap: defaultExtensionMap,
2123
}
2224

2325
export const ssgBuild = (options?: SSGOptions): Plugin => {
@@ -90,7 +92,11 @@ export const ssgBuild = (options?: SSGOptions): Plugin => {
9092
return
9193
},
9294
},
93-
{ dir: outDir, plugins: options?.plugins ?? defaultOptions.plugins }
95+
{
96+
dir: outDir,
97+
plugins: options?.plugins ?? defaultOptions.plugins,
98+
extensionMap: options?.extensionMap ?? defaultOptions.extensionMap,
99+
}
94100
)
95101

96102
server.close()

0 commit comments

Comments
 (0)