-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite-build.config.ts
84 lines (82 loc) · 2.11 KB
/
vite-build.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
import react from '@vitejs/plugin-react'
import postCSSPresetMantine from 'postcss-preset-mantine'
import postCSSSimpleVars from 'postcss-simple-vars'
import { preserveDirectives } from 'rollup-plugin-preserve-directives'
import type { UserConfigExport } from 'vite'
import { defineConfig } from 'vite'
import dts from 'vite-plugin-dts'
import { externalizeDeps } from 'vite-plugin-externalize-deps'
import tsconfigPaths from 'vite-tsconfig-paths'
const buildOutputDir = 'dist'
const rootDir = './src/lib'
const entryFile = `${rootDir}/index.ts`
const app = async (): Promise<UserConfigExport> => {
return defineConfig({
plugins: [
react(),
externalizeDeps({
include: [],
}),
preserveDirectives(),
tsconfigPaths(),
dts({
outDir: `${buildOutputDir}/esm`,
entryRoot: rootDir,
include: rootDir,
compilerOptions: {
module: 99,
declarationMap: false,
},
}),
dts({
outDir: `${buildOutputDir}/cjs`,
entryRoot: rootDir,
include: rootDir,
compilerOptions: {
module: 1,
declarationMap: false,
},
}),
],
css: {
modules: {
localsConvention: 'camelCase',
},
postcss: {
plugins: [
postCSSPresetMantine(),
postCSSSimpleVars({
variables: {
'mantine-breakpoint-xs': '36em',
'mantine-breakpoint-sm': '48em',
'mantine-breakpoint-md': '62em',
'mantine-breakpoint-lg': '75em',
'mantine-breakpoint-xl': '88em',
},
})
],
}
},
build: {
outDir: buildOutputDir,
minify: true,
sourcemap: true,
lib: {
entry: entryFile,
formats: ['es', 'cjs'],
fileName: (format) => {
if (format === 'cjs') return 'cjs/[name].cjs'
return 'esm/[name].js'
},
},
rollupOptions: {
output: {
preserveModules: true,
exports: 'named',
},
}
}
})
}
// https://vitejs.dev/config/
export default app