Skip to content

Commit 8df71db

Browse files
authored
feat: change config hook to configResolved, avoid cacheDir different … (#4)
1 parent b2d498c commit 8df71db

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

src/index.ts

+3-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable node/no-extraneous-import */
21
import path from 'node:path'
32
import { promises as fsp } from 'node:fs'
43
import type { Plugin } from 'vite'
@@ -8,15 +7,13 @@ const defaultCacheDir = 'node_modules/.vite'
87
function viteBasicSslPlugin(): Plugin {
98
return {
109
name: 'vite:basic-ssl',
11-
async config(config) {
10+
async configResolved(config) {
1211
const certificate = await getCertificate((config.cacheDir ?? defaultCacheDir) + '/basic-ssl')
1312
const https = () => ({
1413
https: { cert: certificate, key: certificate }
1514
})
16-
return {
17-
server: https(),
18-
preview: https()
19-
}
15+
config.server.https = Object.assign({}, config.server.https, https())
16+
config.preview.https = Object.assign({}, config.preview.https, https())
2017
}
2118
}
2219
}

0 commit comments

Comments
 (0)