Skip to content

Commit 05d9942

Browse files
authored
feat(vite-plugin-tempest): allow overriding configuration using TEMPEST_PLUGIN_CONFIGURATION_OVERRIDE (#1256)
1 parent 7b3cc70 commit 05d9942

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

packages/vite-plugin-tempest/src/config.test.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,19 @@ test('the configuration can be loaded', async () => {
1212
expect(config).toHaveProperty('manifest')
1313
expect(config).toHaveProperty('entrypoints')
1414
})
15+
16+
test('the configuration can be overriden', async () => {
17+
process.env.TEMPEST_PLUGIN_CONFIGURATION_OVERRIDE = JSON.stringify({
18+
build_directory: 'build',
19+
bridge_file_name: 'vite-tempest',
20+
manifest: 'manifest.json',
21+
entrypoints: [],
22+
})
23+
24+
const config = await loadTempestConfiguration()
25+
26+
expect(config).toHaveProperty('build_directory')
27+
expect(config).toHaveProperty('bridge_file_name')
28+
expect(config).toHaveProperty('manifest')
29+
expect(config).toHaveProperty('entrypoints')
30+
})

packages/vite-plugin-tempest/src/config.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ const VITE_CONFIG_COMMAND = 'vite:config'
66

77
export async function loadTempestConfiguration(): Promise<TempestViteConfiguration> {
88
try {
9+
const override = process.env.TEMPEST_PLUGIN_CONFIGURATION_OVERRIDE
10+
if (override) {
11+
return JSON.parse(override)
12+
}
13+
914
const { stdout } = await exec(`${php.value} ${TEMPEST_BIN} ${VITE_CONFIG_COMMAND}`)
1015
const json = stdout.match(/\{.*\}/s)
1116

0 commit comments

Comments
 (0)