aboutsummaryrefslogtreecommitdiff
path: root/packages/studip-ui/vite.config.js
blob: c83c20dad7f0637d172c1d68dcec683e2929bf9a (plain)
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
import { resolve } from 'node:path'
import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'

const srcDir = fileURLToPath(new URL('./src', import.meta.url))
const componentsDir = fileURLToPath(new URL('./src/components', import.meta.url))

export default defineConfig({
    build: {
        sourcemap: true,
        target: 'es2020',
        lib: {
            entry: {
                'studip-ui': resolve('src/main.js'),
                'components/index': resolve('src/components/index.js'),
                'composables/index': resolve('src/composables/index.js'),
            },
            name: 'StudipUi',
        },
        rollupOptions: {
            external: ['vue'],
            output: {
                globals: {
                    vue: 'Vue',
                },
                manualChunks(id) {
                    if (id.startsWith(componentsDir) && !id.includes('index.js')) {
                        return 'components/index'
                    }
                    return null
                },
            },
        },
    },
    plugins: [vue()],
    resolve: {
        alias: {
            '@studip-ui': srcDir,
        },
    },
})