-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
48 lines (46 loc) · 1.17 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
import path from 'path'
import { defineConfig } from 'vite'
import { name } from './package.json'
import babel from '@rollup/plugin-babel'
import vue from '@vitejs/plugin-vue'
const camelize = (name: string) =>
name.replace(/(^|-)(\w)/g, (a, b, c) => c.toUpperCase())
export default defineConfig({
root: path.resolve(__dirname, 'example'),
resolve: {
alias: {
'/@src': path.resolve(__dirname, 'src'),
},
},
build: {
target: 'es2015',
outDir: path.resolve(__dirname, 'lib'),
lib: {
entry: path.resolve(__dirname, 'src/index.ts'),
name: camelize(name),
},
rollupOptions: {
output: {
exports: 'named',
globals: (id: string) => {
const name = id.replace(/^@/, '').split('/')[0]
return camelize(name)
},
assetFileNames: 'index.css',
},
plugins: [
babel({
exclude: 'node_modules/**',
extensions: ['.js', '.jsx', '.ts', '.tsx', '.vue'],
presets: ['@babel/preset-env', '@babel/preset-typescript'],
}),
],
external: ['vue', 'vue-router'],
},
},
plugins: [
vue({
include: [/\.vue$/, /\.md$/],
}),
]
})