test: add deterministic resilience matrix
This commit is contained in:
@@ -2,12 +2,27 @@ import { fileURLToPath, URL } from 'node:url';
|
||||
import { defineConfig } from 'vite';
|
||||
import vue from '@vitejs/plugin-vue';
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [vue()],
|
||||
build: {
|
||||
sourcemap: false,
|
||||
},
|
||||
resolve: {
|
||||
alias: { '@': fileURLToPath(new URL('./src', import.meta.url)) },
|
||||
},
|
||||
export default defineConfig(() => {
|
||||
const testBuild = process.env.PORTFOLIO_TEST_BUILD === '1';
|
||||
const testTokenDigest = process.env.PORTFOLIO_TEST_TOKEN_DIGEST ?? '';
|
||||
if (testBuild && !/^[a-f0-9]{64}$/u.test(testTokenDigest)) {
|
||||
throw new Error('Authenticated test builds require one SHA-256 token digest.');
|
||||
}
|
||||
if (!testBuild && testTokenDigest !== '') {
|
||||
throw new Error('A test token digest cannot influence a production build.');
|
||||
}
|
||||
|
||||
return {
|
||||
plugins: [vue()],
|
||||
define: {
|
||||
__PORTFOLIO_TEST_BUILD__: JSON.stringify(testBuild),
|
||||
__PORTFOLIO_TEST_TOKEN_DIGEST__: JSON.stringify(testBuild ? testTokenDigest : ''),
|
||||
},
|
||||
build: {
|
||||
sourcemap: false,
|
||||
},
|
||||
resolve: {
|
||||
alias: { '@': fileURLToPath(new URL('./src', import.meta.url)) },
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user