This commit makes the build process more robust, simplifies configurations and reduce the risk of incomplete or erroneous deployments. - Centralize output directory definitions by introducing `dist-dirs.json`. - Add `verify-build-artifacts` utility to ensure correct build outputs and `print-dist-dir` to determine distribution directory. - Add steps in CI/CD pipeline to verify build artifacts. - Migrate Electron Builder config from YAML to CJS for capability to read JSON. - Fix `release-site.yaml` failing due to pointing to wrong distribution directory, change it to use `print-dist-dir`. - Improve `check-desktop-runtime-errors` to verify build artifacts for more reliable builds. Ensure tests fail and succeed reliably. - Update `.gitignore` and configure ESLint to use it to define and ignore build artifact directories from one place, remove `.eslintignore` that does not add anything after this change. - Keep `"main"` field in `package.json` as `electron-vite` depends on it (alex8088/electron-vite#270). - Improve documentation
58 lines
1.5 KiB
TypeScript
58 lines
1.5 KiB
TypeScript
/// <reference types="vitest" />
|
|
import { resolve } from 'path';
|
|
import { defineConfig, UserConfig } from 'vite';
|
|
import legacy from '@vitejs/plugin-legacy';
|
|
import vue from '@vitejs/plugin-vue2';
|
|
import ViteYaml from '@modyfi/vite-plugin-yaml';
|
|
import distDirs from './dist-dirs.json' assert { type: 'json' };
|
|
import { getAliasesFromTsConfig, getClientEnvironmentVariables, getSelfDirectoryAbsolutePath } from './vite-config-helper';
|
|
|
|
const WEB_DIRECTORY = resolve(getSelfDirectoryAbsolutePath(), 'src/presentation');
|
|
const TEST_INITIALIZATION_FILE = resolve(getSelfDirectoryAbsolutePath(), 'tests/shared/bootstrap/setup.ts');
|
|
|
|
export function createVueConfig(options?: {
|
|
readonly supportLegacyBrowsers: boolean,
|
|
}): UserConfig {
|
|
return {
|
|
root: WEB_DIRECTORY,
|
|
build: {
|
|
outDir: resolve(getSelfDirectoryAbsolutePath(), distDirs.web),
|
|
},
|
|
plugins: [
|
|
vue(),
|
|
ViteYaml(),
|
|
...[options?.supportLegacyBrowsers ? legacy() : undefined],
|
|
],
|
|
esbuild: {
|
|
supported: {
|
|
'top-level-await': true, // Exclude browsers not supporting top-level-await
|
|
},
|
|
},
|
|
define: {
|
|
...getClientEnvironmentVariables(),
|
|
},
|
|
resolve: {
|
|
alias: {
|
|
...getAliasesFromTsConfig(),
|
|
},
|
|
},
|
|
server: {
|
|
port: 3169,
|
|
},
|
|
test: {
|
|
globals: true,
|
|
environment: 'jsdom',
|
|
alias: {
|
|
...getAliasesFromTsConfig(),
|
|
},
|
|
setupFiles: [
|
|
TEST_INITIALIZATION_FILE,
|
|
],
|
|
},
|
|
};
|
|
}
|
|
|
|
export default defineConfig(createVueConfig({
|
|
supportLegacyBrowsers: true,
|
|
}));
|