-
-
Notifications
You must be signed in to change notification settings - Fork 12
/
vite.config.ts
87 lines (81 loc) · 2.86 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
import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import pkg from './package.json' with { type: 'json' };
import { viteStaticCopy } from 'vite-plugin-static-copy';
import { compileString, compileStringAsync } from 'sass';
const banner = `
/*! ================================
${pkg.name} v${pkg.version}
(c) 2019-present ${pkg.author}
Released under ${pkg.license} License
================================== */
`;
export default defineConfig(({ mode }) => {
const config: Parameters<typeof defineConfig>[0] = {
plugins: [
vue(),
viteStaticCopy({
targets: [
{
src: ['src/assets/themes/*.scss', '!src/assets/themes/common.scss'],
dest: 'themes',
rename: (fileName) => {
return `${fileName}.css`;
},
transform: (content) => {
return compileString(
content,
{
syntax: 'scss',
style: 'compressed',
// required to be able to resolve common.scss
loadPaths: ['src/assets/themes']
}
).css;
}
}
]
})
],
define: {
// eslint-disable-next-line @typescript-eslint/naming-convention
__VUE_OPTIONS_API__: false
}
};
if (mode === 'library') {
config.build = {
minify: true,
copyPublicDir: false,
lib: {
entry: {
'index': 'src/index.ts',
'useToast': 'src/composables/useToast.ts',
'useVtEvents': 'src/composables/useVtEvents.ts',
'useVtSettings': 'src/composables/useSettings.ts'
},
name: pkg.name,
fileName: (format, entryName) => {
if (format === 'es') {
return `${entryName}.mjs`;
}
if (format === 'cjs') {
return `${entryName}.cjs`;
}
return `${entryName}.${format}.js`;
}
},
rollupOptions: {
external: ['vue'],
output: {
globals: {
vue: 'Vue'
},
assetFileNames: assetInfo => assetInfo.name === 'style.css' ? 'index.css' :assetInfo.name!,
exports: 'named',
banner
}
}
};
}
return config;
});