Skip to content

Commit 64d7852

Browse files
committed
feat: allow for vite plugin usage
1 parent a8566e0 commit 64d7852

File tree

3 files changed

+24
-15
lines changed

3 files changed

+24
-15
lines changed

src/config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export const defaultConfig: ReverseProxyConfig = {
1414
keyPath: join(homedir(), '.stacks', 'ssl', `stacks.localhost.crt.key`),
1515
},
1616
etcHostsCleanup: true,
17+
vitePluginUsage: false,
1718
verbose: true,
1819
}
1920

src/start.ts

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,7 @@ async function createProxyServer(
285285
hostname: string,
286286
sourceUrl: Pick<URL, 'hostname' | 'host'>,
287287
ssl: SSLConfig | null,
288+
vitePluginUsage?: boolean,
288289
verbose?: boolean,
289290
cleanUrls?: boolean,
290291
): Promise<void> {
@@ -450,21 +451,23 @@ async function createProxyServer(
450451
server.listen(listenPort, hostname, () => {
451452
debugLog('server', `Server listening on port ${listenPort}`, verbose)
452453

453-
console.log('')
454-
console.log(` ${green(bold('reverse-proxy'))} ${green(`v${version}`)}`)
455-
console.log('')
456-
console.log(` ${green('➜')} ${dim(from)} ${dim('➜')} ${ssl ? 'https' : 'http'}://${to}`)
457-
if (listenPort !== (ssl ? 443 : 80))
458-
console.log(` ${green('➜')} Listening on port ${listenPort}`)
459-
if (ssl) {
460-
console.log(` ${green('➜')} SSL enabled with:`)
461-
console.log(` - TLS 1.2/1.3`)
462-
console.log(` - Modern cipher suite`)
463-
console.log(` - HTTP/2 enabled`)
464-
console.log(` - HSTS enabled`)
465-
}
466-
if (cleanUrls) {
467-
console.log(` ${green('➜')} Clean URLs enabled`)
454+
if (!vitePluginUsage) {
455+
console.log('')
456+
console.log(` ${green(bold('reverse-proxy'))} ${green(`v${version}`)}`)
457+
console.log('')
458+
console.log(` ${green('➜')} ${dim(from)} ${dim('➜')} ${ssl ? 'https' : 'http'}://${to}`)
459+
if (listenPort !== (ssl ? 443 : 80))
460+
console.log(` ${green('➜')} Listening on port ${listenPort}`)
461+
if (ssl) {
462+
console.log(` ${green('➜')} SSL enabled with:`)
463+
console.log(` - TLS 1.2/1.3`)
464+
console.log(` - Modern cipher suite`)
465+
console.log(` - HTTP/2 enabled`)
466+
console.log(` - HSTS enabled`)
467+
}
468+
if (cleanUrls) {
469+
console.log(` ${green('➜')} Clean URLs enabled`)
470+
}
468471
}
469472

470473
resolve()
@@ -562,6 +565,7 @@ export function startProxy(options: ReverseProxyOption): void {
562565
cleanUrls: mergedOptions.cleanUrls,
563566
https: httpsConfig(mergedOptions),
564567
etcHostsCleanup: mergedOptions.etcHostsCleanup,
568+
vitePluginUsage: mergedOptions.vitePluginUsage,
565569
verbose: mergedOptions.verbose,
566570
}
567571

@@ -620,6 +624,7 @@ export async function startProxies(options?: ReverseProxyOptions): Promise<void>
620624
https: mergedOptions.https,
621625
etcHostsCleanup: mergedOptions.etcHostsCleanup,
622626
cleanUrls: mergedOptions.cleanUrls,
627+
vitePluginUsage: mergedOptions.vitePluginUsage,
623628
verbose: mergedOptions.verbose,
624629
_cachedSSLConfig: mergedOptions._cachedSSLConfig,
625630
}))
@@ -629,6 +634,7 @@ export async function startProxies(options?: ReverseProxyOptions): Promise<void>
629634
cleanUrls: mergedOptions.cleanUrls || false,
630635
https: mergedOptions.https,
631636
etcHostsCleanup: mergedOptions.etcHostsCleanup,
637+
vitePluginUsage: mergedOptions.vitePluginUsage,
632638
verbose: mergedOptions.verbose,
633639
_cachedSSLConfig: mergedOptions._cachedSSLConfig,
634640
}]
@@ -665,6 +671,7 @@ export async function startProxies(options?: ReverseProxyOptions): Promise<void>
665671
cleanUrls: option.cleanUrls || false,
666672
https: option.https || false,
667673
etcHostsCleanup: option.etcHostsCleanup || false,
674+
vitePluginUsage: option.vitePluginUsage || false,
668675
verbose: option.verbose || false,
669676
_cachedSSLConfig: sslConfig,
670677
})

src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export interface CleanupOptions {
1616
export interface SharedProxyConfig {
1717
https: boolean | TlsOption
1818
etcHostsCleanup: boolean
19+
vitePluginUsage: boolean
1920
verbose: boolean
2021
_cachedSSLConfig?: SSLConfig | null
2122
}

0 commit comments

Comments
 (0)