2023-05-25 02:40:08 +00:00
|
|
|
import react from '@vitejs/plugin-react';
|
|
|
|
import { defineConfig } from 'vitest/config';
|
2023-09-15 00:51:20 +00: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 02:40:08 +00:00
|
|
|
|
|
|
|
export default defineConfig({
|
|
|
|
plugins: [react()],
|
2023-06-07 02:37:10 +00:00
|
|
|
resolve: {
|
|
|
|
mainFields: ['module'],
|
|
|
|
},
|
2023-05-25 02:40:08 +00:00
|
|
|
test: {
|
|
|
|
globals: true,
|
|
|
|
setupFiles: 'scripts/setupVitest.ts',
|
|
|
|
environment: 'jsdom',
|
2023-06-07 02:37:10 +00:00
|
|
|
css: false,
|
2023-05-25 02:40:08 +00:00
|
|
|
threads: true,
|
|
|
|
alias: [
|
2023-06-07 07:42:57 +00:00
|
|
|
{ find: 'testUtils', replacement: 'testUtils.ts' },
|
2023-06-07 02:37:10 +00:00
|
|
|
{ find: /^~antd\/(.*)/, replacement: 'antd/$1' },
|
2023-09-15 00:51:20 +00:00
|
|
|
...alias,
|
2023-05-25 02:40:08 +00: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 01:58:49 +00:00
|
|
|
// 在 GitHub Actions 中不输出日志
|
|
|
|
silent: !!process.env.GITHUB_ACTIONS,
|
2023-09-05 02:26:01 +00:00
|
|
|
server: {
|
|
|
|
deps: {
|
|
|
|
inline: ['@juggle/resize-observer', 'clsx'],
|
|
|
|
},
|
|
|
|
},
|
2023-05-25 02:40:08 +00:00
|
|
|
},
|
|
|
|
});
|