29 lines
926 B
TypeScript
29 lines
926 B
TypeScript
import { fileURLToPath, URL } from 'node:url';
|
|
import { defineConfig } from 'vite';
|
|
import vue from '@vitejs/plugin-vue';
|
|
|
|
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)) },
|
|
},
|
|
};
|
|
});
|