-
Notifications
You must be signed in to change notification settings - Fork 19
/
vite.config.mts
55 lines (51 loc) · 1.4 KB
/
vite.config.mts
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
import { fileURLToPath, URL } from 'node:url';
import { resolve } from 'node:path';
import { defineConfig, type UserConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import VueDevTools from 'vite-plugin-vue-devtools';
import dts from 'vite-plugin-dts';
const siteBuildConfig: UserConfig['build'] = {};
const libBuildConfig: UserConfig['build'] = {
lib: {
entry: resolve(__dirname, 'src/lib.ts'),
name: 'vcdonut',
fileName: 'vcdonut',
formats: ['es', 'umd'],
},
rollupOptions: {
external: ['vue'],
output: {
globals: {
vue: 'Vue',
},
assetFileNames: 'vcdonut.[ext]',
// https://rollupjs.org/configuration-options/#output-exports
exports: 'named',
},
},
sourcemap: true,
};
const plugins: UserConfig['plugins'] = [vue(), VueDevTools()];
if (process.env.BUILD_TARGET === 'lib') {
plugins.push(
dts({
tsconfigPath: resolve(__dirname, 'tsconfig.app.json'),
rollupTypes: true,
}),
);
}
// https://vitejs.dev/config/
export default defineConfig({
base: process.env.BUILD_TARGET === 'site' ? '/vue-css-donut-chart/' : undefined,
plugins,
build: (() => {
if (process.env.BUILD_TARGET === 'site') return siteBuildConfig;
if (process.env.BUILD_TARGET === 'lib') return libBuildConfig;
return undefined;
})(),
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url)),
},
},
});