2023-05-25 10:40:08 +08:00
|
|
|
import react from '@vitejs/plugin-react';
|
|
|
|
import { defineConfig } from 'vitest/config';
|
2023-09-15 08:51:20 +08:00
|
|
|
import tsConfigPaths from './tsconfig.paths.json';
|
|
|
|
|
|
|
|
const paths = tsConfigPaths.compilerOptions.paths;
|
|
|
|
|
|
|
|
const alias = Object.keys(paths).reduce<{ find: string; replacement: string }[]>((acc, key) => {
|
|
|
|
if (key !== '@@/*') {
|
|
|
|
const value = paths[key][0];
|
|
|
|
acc.push({
|
|
|
|
find: key,
|
|
|
|
replacement: value,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
return acc;
|
|
|
|
}, []);
|
2023-05-25 10:40:08 +08:00
|
|
|
|
|
|
|
export default defineConfig({
|
|
|
|
plugins: [react()],
|
2023-06-07 10:37:10 +08:00
|
|
|
resolve: {
|
|
|
|
mainFields: ['module'],
|
|
|
|
},
|
2023-05-25 10:40:08 +08:00
|
|
|
test: {
|
|
|
|
globals: true,
|
|
|
|
setupFiles: 'scripts/setupVitest.ts',
|
|
|
|
environment: 'jsdom',
|
2023-06-07 10:37:10 +08:00
|
|
|
css: false,
|
2023-05-25 10:40:08 +08:00
|
|
|
threads: true,
|
|
|
|
alias: [
|
2023-06-07 15:42:57 +08:00
|
|
|
{ find: 'testUtils', replacement: 'testUtils.ts' },
|
2023-06-07 10:37:10 +08:00
|
|
|
{ find: /^~antd\/(.*)/, replacement: 'antd/$1' },
|
2023-09-15 08:51:20 +08:00
|
|
|
...alias,
|
2023-05-25 10:40:08 +08:00
|
|
|
],
|
|
|
|
include: ['packages/**/{dumi-theme-nocobase,sdk,client}/**/__tests__/**/*.{test,spec}.{ts,tsx}'],
|
|
|
|
exclude: ['**/node_modules/**', '**/dist/**', '**/lib/**', '**/es/**', '**/{vitest,commitlint}.config.*'],
|
|
|
|
testTimeout: 300000,
|
|
|
|
bail: 1,
|
2023-07-28 09:58:49 +08:00
|
|
|
// 在 GitHub Actions 中不输出日志
|
|
|
|
silent: !!process.env.GITHUB_ACTIONS,
|
2023-09-05 10:26:01 +08:00
|
|
|
server: {
|
|
|
|
deps: {
|
|
|
|
inline: ['@juggle/resize-observer', 'clsx'],
|
|
|
|
},
|
|
|
|
},
|
2023-05-25 10:40:08 +08:00
|
|
|
},
|
|
|
|
});
|