File tree Expand file tree Collapse file tree 2 files changed +18
-3
lines changed
packages/vite-plugin-tempest/src Expand file tree Collapse file tree 2 files changed +18
-3
lines changed Original file line number Diff line number Diff line change 11import type { TempestViteConfiguration } from './types'
22import { exec , php } from './utils'
3+ import { readFileSync } from 'node:fs' ;
4+ import { resolve } from 'node:path' ;
35
46const TEMPEST_BIN = 'tempest'
57const VITE_CONFIG_COMMAND = 'vite:config'
68
7- export async function loadTempestConfiguration ( ) : Promise < TempestViteConfiguration > {
9+ export async function loadTempestConfiguration (
10+ options : { config_file_path ?: string } = { }
11+ ) : Promise < TempestViteConfiguration > {
12+ if ( options . config_file_path ) {
13+ try {
14+ const filePath = resolve ( process . cwd ( ) , options . config_file_path ) ;
15+ const fileContent = readFileSync ( filePath , 'utf-8' ) ;
16+ return JSON . parse ( fileContent ) ;
17+ } catch ( e ) {
18+ console . error ( `[vite-plugin-tempest] Error: Failed to read or parse the file at [${ options . config_file_path } ].` ) ;
19+ throw e ;
20+ }
21+ }
22+
823 try {
924 const override = process . env . TEMPEST_PLUGIN_CONFIGURATION_OVERRIDE
1025 if ( override ) {
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ const TEMPEST_ORIGIN_PLACEHOLDER = 'http://__tempest_placeholder__.test'
1515
1616let exitHandlersBound = false
1717
18- export default function tempest ( ) : Plugin {
18+ export default function tempest ( options : { config_file_path ?: string } = { } ) : Plugin {
1919 let viteDevServerUrl : DevelopmentServerUrl
2020 let bridgeFilePath : string
2121 let resolvedConfig : ResolvedConfig
@@ -30,7 +30,7 @@ export default function tempest(): Plugin {
3030 name : 'tempest' ,
3131 enforce : 'post' ,
3232 config : async ( config , { command, mode } ) => {
33- tempestConfig = await loadTempestConfiguration ( )
33+ tempestConfig = await loadTempestConfiguration ( options )
3434 userConfig = config
3535
3636 const ssr = ! ! userConfig . build ?. ssr
You can’t perform that action at this time.
0 commit comments