forked from qmhc/grid-layout-plus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
66 lines (62 loc) · 1.66 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
import { resolve } from 'node:path'
import { readFileSync } from 'node:fs'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import cssInject from 'vite-plugin-css-injected-by-js'
import autoprefixer from 'autoprefixer'
interface Manifest {
dependencies?: Record<string, string>,
peerDependencies?: Record<string, string>,
version?: string
}
const pkg = JSON.parse(readFileSync(resolve(__dirname, 'package.json'), 'utf-8')) as Manifest
const externalPkgs = ['@vue'].concat(
Object.keys(pkg.dependencies || {}),
Object.keys(pkg.peerDependencies || {})
)
const external = (id: string) => externalPkgs.some(p => p === id || id.startsWith(`${p}/`))
export default defineConfig(async () => {
return {
esbuild: {
drop: ['debugger'],
pure: ['console.log']
},
css: {
postcss: {
plugins: [autoprefixer]
}
},
build: {
outDir: 'es',
sourcemap: true,
lib: {
entry: resolve(__dirname, 'src/index.ts'),
formats: ['es']
},
rollupOptions: {
input: [resolve(__dirname, 'src/index.ts')],
external,
output: [
{
format: 'cjs',
preserveModules: true,
preserveModulesRoot: resolve(__dirname, 'src'),
dir: 'lib',
entryFileNames: '[name].js'
},
{
format: 'es',
preserveModules: true,
preserveModulesRoot: resolve(__dirname, 'src'),
dir: 'es',
entryFileNames: '[name].mjs'
}
]
},
commonjsOptions: {
sourceMap: false
}
},
plugins: [vue(), cssInject()]
}
})