This commit progresses the migration from Vue CLI to Vite (#230). TypeScript migration: - Convert JavaScript Cypress tests and configurations to TypeScript. - Introduce `tsconfig.json` for Cypress, following official recommendation. Test execution: - Use Cypress CLI to run the tests. - Rename Cypress commands to reflect official naming conventions. - Start Vue server prior to Cypress execution, using `start-server-and-test` package based on official documentation. - Remove dependency on Vue CLI plugin ((`@vue/cli-plugin-e2e-cypress`). Configuration standardization (based on Cypress docs): - Delete unused `plugins/` directory. - Move test (spec) files to to the root directory. - Add official ESLint plugin (`eslint-plugin-cypress`). Changes for importing `vite.config.ts` into `cypress.config.ts`: - Add TypeScript import assertations to files importing JSON files. - Use ESM friendly way instead of `__dirname` to solve `ReferenceError: __dirname is not defined in ES module scrope`. Other changes: - Simplify comments in placeholder files. - Create Cypress specific `.gitignore` for enhanced maintainability, clarity and scalability. - Remove redundant `vue.config.cjs`.
55 lines
1.4 KiB
TypeScript
55 lines
1.4 KiB
TypeScript
/// <reference types="vitest" />
|
|
import { resolve } from 'path';
|
|
import { defineConfig } from 'vite';
|
|
import legacy from '@vitejs/plugin-legacy';
|
|
import vue from '@vitejs/plugin-vue2';
|
|
import ViteYaml from '@modyfi/vite-plugin-yaml';
|
|
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');
|
|
const NODE_CORE_MODULES = ['os', 'child_process', 'fs', 'path'];
|
|
|
|
export default defineConfig({
|
|
root: WEB_DIRECTORY,
|
|
plugins: [
|
|
vue(),
|
|
ViteYaml(),
|
|
legacy(),
|
|
],
|
|
esbuild: {
|
|
supported: {
|
|
'top-level-await': true, // Exclude browsers not supporting top-level-await
|
|
},
|
|
},
|
|
define: {
|
|
...getClientEnvironmentVariables(),
|
|
},
|
|
resolve: {
|
|
alias: {
|
|
...getAliasesFromTsConfig(),
|
|
},
|
|
},
|
|
build: {
|
|
rollupOptions: {
|
|
// Ensure Node core modules are externalized and don't trigger warnings in browser builds
|
|
external: {
|
|
...NODE_CORE_MODULES,
|
|
},
|
|
},
|
|
},
|
|
server: {
|
|
port: 3169,
|
|
},
|
|
test: {
|
|
globals: true,
|
|
environment: 'jsdom',
|
|
alias: {
|
|
...getAliasesFromTsConfig(),
|
|
},
|
|
setupFiles: [
|
|
TEST_INITIALIZATION_FILE,
|
|
],
|
|
},
|
|
});
|