-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.shared.ts
More file actions
64 lines (61 loc) · 2.3 KB
/
vite.shared.ts
File metadata and controls
64 lines (61 loc) · 2.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/// <reference types='vitest' />
import type { UserConfig } from 'vite';
import { nxCopyAssetsPlugin } from '@nx/vite/plugins/nx-copy-assets.plugin';
import tsconfigPaths from 'vite-tsconfig-paths';
import dts from 'vite-plugin-dts';
import { join } from 'path';
// Common shared Vite configuration for all packages. Keep this file limited to
// settings that are identical across packages (build/test defaults).
const packagesPath = join(__dirname, 'packages');
export function createSharedConfig(packageDirPath: string): UserConfig {
if (!packageDirPath.startsWith(packagesPath)) {
throw new Error(`Invalid package directory: ${packageDirPath}`);
}
const packageDirname = packageDirPath.replace(packagesPath, '');
return {
root: packageDirPath,
cacheDir: join(__dirname, 'node_modules/.vite/packages/', packageDirname),
plugins: [
// enable TS path mapping resolution during dev/test
tsconfigPaths(),
nxCopyAssetsPlugin(['*.md', 'package.json']),
dts({
entryRoot: 'src',
tsconfigPath: join(packageDirPath, 'tsconfig.lib.json'),
}),
],
build: {
outDir: './dist',
emptyOutDir: true,
reportCompressedSize: true,
commonjsOptions: {
transformMixedEsModules: true,
},
// target and ssr are common for node libraries in this workspace
target: 'node20',
ssr: true,
rollupOptions: {
external: [
"inversify",
"reflect-metadata",
"@ci-dokumentor/cicd-github-actions",
"@ci-dokumentor/cicd-gitlab-ci",
"@ci-dokumentor/core",
"@ci-dokumentor/repository-git",
"@ci-dokumentor/repository-github",
"@ci-dokumentor/repository-gitlab",
],
},
},
test: {
watch: false,
globals: true,
environment: 'node',
include: ['{src,__tests__}/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
reporters: ['default'],
coverage: {
provider: 'v8' as const,
},
},
};
}