48 lines
1.4 KiB
TypeScript
48 lines
1.4 KiB
TypeScript
import { fileURLToPath, URL } from 'node:url'
|
|
|
|
import vue from '@vitejs/plugin-vue'
|
|
import { defineConfig, loadEnv } from 'vite'
|
|
|
|
export default defineConfig(({ mode }) => {
|
|
const fileEnv = loadEnv(mode, process.cwd(), '')
|
|
const configuredEnv = { ...fileEnv, ...process.env }
|
|
const fixtureBuildEnabled = mode === 'test' || (
|
|
mode !== 'production'
|
|
&& configuredEnv.VITE_EMPLOYEE_WORKBENCH_USE_DEMO_FIXTURES === 'true'
|
|
)
|
|
const fixtureModule = fixtureBuildEnabled
|
|
? './src/features/employee-workbench/fixtures/employeeDemoFixtures.ts'
|
|
: './src/features/employee-workbench/fixtures/employeeDemoFixtures.disabled.ts'
|
|
|
|
return {
|
|
plugins: [vue()],
|
|
define: {
|
|
__EMPLOYEE_DEMO_FIXTURE_MODULE_INCLUDED__: JSON.stringify(fixtureBuildEnabled),
|
|
},
|
|
resolve: {
|
|
alias: [
|
|
{
|
|
find: /^@\/features\/employee-workbench\/fixtures\/employeeDemoFixtures$/,
|
|
replacement: fileURLToPath(new URL(fixtureModule, import.meta.url)),
|
|
},
|
|
{
|
|
find: '@',
|
|
replacement: fileURLToPath(new URL('./src', import.meta.url)),
|
|
},
|
|
],
|
|
},
|
|
server: {
|
|
host: '127.0.0.1',
|
|
port: 5178,
|
|
proxy: configuredEnv.VITE_API_PROXY_TARGET
|
|
? {
|
|
'/api': {
|
|
target: configuredEnv.VITE_API_PROXY_TARGET,
|
|
changeOrigin: true,
|
|
},
|
|
}
|
|
: undefined,
|
|
},
|
|
}
|
|
})
|