afv-library/samples/ui-bundle-template-app-react-sample-b2e/force-app/main/default/uiBundles/propertymanagementapp/vite.config.ts
k-j-kim 92cae58d5f
Rename webapp-template npm packages to ui-bundle-template @W-21338965@ (#135)
* chore: rename webapp-template packages to ui-bundle-template

* chore: sync React b2e and b2x samples from npm @1.117.3

* chore: rename sample folders to match ui-bundle-template package names

* chore: sync React b2e and b2x samples from npm @1.117.5

* chore: remove accidental trace.md from b2e sample

* chore: keep old webapp-template sample directories alongside new ui-bundle-template ones

* chore: revert component.md change from skills/generating-webapplication-ui

* chore: update ui-bundle-template sample versions to 1.117.5
2026-03-30 15:50:18 -05:00

107 lines
2.9 KiB
TypeScript

import { existsSync } from 'node:fs';
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import path from 'path';
import { resolve } from 'path';
import tailwindcss from '@tailwindcss/vite';
import salesforce from '@salesforce/vite-plugin-ui-bundle';
import codegen from 'vite-plugin-graphql-codegen';
const schemaPath = resolve(__dirname, '../../../../../schema.graphql');
const schemaExists = existsSync(schemaPath);
export default defineConfig(({ mode }) => {
return {
base: './',
plugins: [
tailwindcss(),
react(),
salesforce(),
// Only add codegen when schema exists (e.g. after `npm run graphql:schema`).
// In CI or when schema is not checked in, skip codegen so build succeeds.
...(schemaExists
? [
codegen({
configFilePathOverride: resolve(__dirname, 'codegen.yml'),
runOnStart: true,
runOnBuild: true,
enableWatcher: true,
throwOnBuild: true,
}),
]
: []),
] as import('vite').PluginOption[],
// Build configuration for MPA
build: {
outDir: resolve(__dirname, 'dist'),
assetsDir: 'assets',
sourcemap: false,
},
// Resolve aliases (shared between build and test)
resolve: {
dedupe: ['react', 'react-dom'],
alias: {
'@': path.resolve(__dirname, './src'),
'@api': path.resolve(__dirname, './src/api'),
'@components': path.resolve(__dirname, './src/components'),
'@utils': path.resolve(__dirname, './src/utils'),
'@styles': path.resolve(__dirname, './src/styles'),
'@assets': path.resolve(__dirname, './src/assets'),
},
},
// Vitest configuration
test: {
// Override root for tests (build uses src/pages as root)
root: resolve(__dirname),
// Use jsdom environment for React component testing
environment: 'jsdom',
// Setup files to run before each test
setupFiles: ['./src/test/setup.ts'],
// Global test patterns
include: [
'src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}',
'src/**/__tests__/**/*.{js,mjs,cjs,ts,mts,cts,jsx,tsx}',
],
// Coverage configuration
coverage: {
provider: 'v8',
reporter: ['text', 'html', 'clover', 'json'],
exclude: [
'node_modules/',
'src/test/',
'src/**/*.d.ts',
'src/main.tsx',
'src/vite-env.d.ts',
'src/components/**/index.ts',
'**/*.config.ts',
'build/',
'dist/',
'coverage/',
'eslint.config.js',
],
thresholds: {
global: {
branches: 85,
functions: 85,
lines: 85,
statements: 85,
},
},
},
// Test timeout
testTimeout: 10000,
// Globals for easier testing
globals: true,
},
};
});