forked from orangehrm/oxd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
44 lines (41 loc) · 1.11 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
import {resolve} from 'path';
import pkg from './package.json';
import vue from '@vitejs/plugin-vue';
import {fileURLToPath, URL} from 'node:url';
import {defineConfig, type UserConfig} from 'vite';
import collectSass from './vite-plugin-collect-scss';
// https://vitejs.dev/config/
export default defineConfig((conf) => {
const mode = conf.mode === 'library' ? 'lib' : 'dev';
const baseConfig: UserConfig = {
plugins: [vue()],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url)),
},
},
css: {
preprocessorOptions: {
scss: {
additionalData: `@import 'src/styles/index.${mode}.scss';`,
},
},
},
};
if (mode === 'lib') {
baseConfig['build'] = {
lib: {
entry: resolve(__dirname, 'src/index.ts'),
name: 'oxd',
formats: ['es', 'umd'],
fileName: (format) => `index.${format}.js`,
},
rollupOptions: {
external: [...Object.keys(pkg.dependencies)],
},
emptyOutDir: false,
};
baseConfig['plugins']?.push(collectSass());
}
return baseConfig;
});