- lazy-load route pages and add entity-based manual chunking in Vite - prevent environment pages from crashing when legacy records miss data - fix sidebar toggle chevron direction and make env forms full width
102 lines
3.0 KiB
TypeScript
102 lines
3.0 KiB
TypeScript
/// <reference types="vitest/config" />
|
|
import { defineConfig } from 'vite';
|
|
import react from '@vitejs/plugin-react';
|
|
import fs from 'node:fs';
|
|
import path from 'node:path';
|
|
import { fileURLToPath } from 'node:url';
|
|
import { storybookTest } from '@storybook/addon-vitest/vitest-plugin';
|
|
import { playwright } from '@vitest/browser-playwright';
|
|
const dirname = typeof __dirname !== 'undefined' ? __dirname : path.dirname(fileURLToPath(import.meta.url));
|
|
const rootPackageJsonPath = path.resolve(dirname, '../package.json');
|
|
const APP_VERSION = (() => {
|
|
try {
|
|
const json = JSON.parse(fs.readFileSync(rootPackageJsonPath, 'utf8')) as {
|
|
version?: string;
|
|
};
|
|
return json.version ?? 'dev';
|
|
} catch {
|
|
return 'dev';
|
|
}
|
|
})();
|
|
|
|
// More info at: https://storybook.js.org/docs/next/writing-tests/integrations/vitest-addon
|
|
export default defineConfig({
|
|
define: {
|
|
__APP_VERSION__: JSON.stringify(APP_VERSION),
|
|
},
|
|
plugins: [react()],
|
|
build: {
|
|
rollupOptions: {
|
|
output: {
|
|
manualChunks(id) {
|
|
if (!id.includes('/client/src/') && !id.includes('/node_modules/')) {
|
|
return;
|
|
}
|
|
|
|
if (id.includes('/node_modules/lucide-react')) {
|
|
return 'icons';
|
|
}
|
|
if (id.includes('/node_modules/monaco-editor') || id.includes('/node_modules/@monaco-editor')) {
|
|
return 'editor';
|
|
}
|
|
if (id.includes('/node_modules/')) {
|
|
return 'vendor';
|
|
}
|
|
|
|
if (id.includes('/src/pages/environment/')) {
|
|
return 'environments';
|
|
}
|
|
if (id.includes('/src/pages/scenario/')) {
|
|
return 'scenarios';
|
|
}
|
|
if (id.includes('/src/pages/run/')) {
|
|
return 'runs';
|
|
}
|
|
if (id.includes('/src/pages/snippet/')) {
|
|
return 'snippets';
|
|
}
|
|
if (id.includes('/src/pages/credential/')) {
|
|
return 'credentials';
|
|
}
|
|
if (id.includes('/src/pages/session/')) {
|
|
return 'sessions';
|
|
}
|
|
if (id.includes('/src/api/')) {
|
|
return 'api';
|
|
}
|
|
},
|
|
},
|
|
},
|
|
},
|
|
server: {
|
|
proxy: {
|
|
'/environments': 'http://localhost:13000',
|
|
'/credentials': 'http://localhost:13000',
|
|
'/snippets': 'http://localhost:13000',
|
|
'/sessions': 'http://localhost:13000',
|
|
'/scenarios': 'http://localhost:13000',
|
|
},
|
|
},
|
|
test: {
|
|
projects: [{
|
|
extends: true,
|
|
plugins: [
|
|
// The plugin will run tests for the stories defined in your Storybook config
|
|
// See options at: https://storybook.js.org/docs/next/writing-tests/integrations/vitest-addon#storybooktest
|
|
storybookTest({
|
|
configDir: path.join(dirname, '.storybook')
|
|
})],
|
|
test: {
|
|
name: 'storybook',
|
|
browser: {
|
|
enabled: true,
|
|
headless: true,
|
|
provider: playwright({}),
|
|
instances: [{
|
|
browser: 'chromium'
|
|
}]
|
|
}
|
|
}
|
|
}]
|
|
}
|
|
}); |