-
Notifications
You must be signed in to change notification settings - Fork 51
/
Copy pathvite.config.ts
88 lines (84 loc) · 2.47 KB
/
vite.config.ts
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/// <reference types='vitest' />
import * as path from 'path'
import { nxCopyAssetsPlugin } from '@nx/vite/plugins/nx-copy-assets.plugin'
import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin'
import react from '@vitejs/plugin-react'
import { defineConfig } from 'vite'
import dts from 'vite-plugin-dts'
export default defineConfig({
root: __dirname,
cacheDir: '../../node_modules/.vite/packages/clouds',
plugins: [
react(),
nxViteTsPaths(),
nxCopyAssetsPlugin(['assets/**/*', 'src/**/*', '*.md']),
dts({
outDir: '../../dist/packages/clouds/types',
entryRoot: 'src',
tsconfigPath: path.join(__dirname, 'tsconfig.lib.json'),
pathsToAliases: false,
afterDiagnostic: diagnostics => {
diagnostics.forEach(diagnostic => {
console.warn(diagnostic)
})
}
})
],
// Uncomment this if you are using workers.
// worker: {
// plugins: [ nxViteTsPaths() ],
// },
// Configuration for building your library.
// See: https://vitejs.dev/guide/build.html#library-mode
build: {
outDir: '../../dist/packages/clouds',
emptyOutDir: true,
reportCompressedSize: true,
commonjsOptions: {
transformMixedEsModules: true
},
lib: {
// Could also be a dictionary or array of multiple entry points.
entry: {
'build/index': 'src/index.ts',
'build/r3f': 'src/r3f/index.ts'
},
name: 'clouds'
},
sourcemap: true,
rollupOptions: {
output: [
{
format: 'es' as const,
chunkFileNames: 'build/shared.js'
},
{
format: 'cjs' as const,
chunkFileNames: 'build/shared.cjs'
}
].map(config => ({
...config,
sourcemapExcludeSources: true,
// Note this just append files in ignore list.
sourcemapIgnoreList: relativeSourcePath =>
relativeSourcePath.includes('node_modules'),
sourcemapPathTransform: relativeSourcePath =>
relativeSourcePath
.replace('../../../../node_modules', '../node_modules')
.replace('../../../../packages/clouds/src', '../src')
})),
// External packages that should not be bundled into your library.
external: [
/^@takram/,
'react',
'react-dom',
'react/jsx-runtime',
'three',
'postprocessing',
'@react-three/fiber',
'@react-three/drei',
'@react-three/postprocessing'
]
}
}
})