forked from vitejs/vite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.js
41 lines (40 loc) · 870 Bytes
/
vite.config.js
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
import fs from 'node:fs'
import path from 'node:path'
import { defineConfig } from 'vite'
export default defineConfig({
esbuild: {
supported: {
// Force esbuild inject helpers to test regex
'object-rest-spread': false,
'optional-chain': false,
},
},
build: {
rollupOptions: {
output: {
banner: `/*!\nMayLib\n*/`,
},
},
lib: {
entry: path.resolve(__dirname, 'src/main.js'),
name: 'MyLib',
formats: ['es', 'umd', 'iife'],
fileName: 'my-lib-custom-filename',
},
},
plugins: [
{
name: 'emit-index',
generateBundle() {
this.emitFile({
type: 'asset',
fileName: 'index.html',
source: fs.readFileSync(
path.resolve(__dirname, 'index.dist.html'),
'utf-8',
),
})
},
},
],
})