-
Notifications
You must be signed in to change notification settings - Fork 1
/
vite.config.base.ts
62 lines (59 loc) · 1.37 KB
/
vite.config.base.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
import { resolve, join } from 'path';
import { readFileSync, copyFileSync } from 'fs';
import { defineConfig } from 'vite';
import dts from 'vite-plugin-dts';
// https://vitejs.dev/config/
export default defineConfig({
build: {
lib: {
entry: resolve(__dirname, 'src/base/index.ts'),
name: 'EmojiParser',
fileName: (format: any) => {
const name = 'quill-emoji-parser';
if (format === 'umd') {
return `${name}.min.js` as string;
}
return `${name}.mjs` as string;
},
formats: ['umd', 'es'],
},
target: 'esnext',
minify: 'terser',
outDir: 'dist',
emptyOutDir: false,
rollupOptions: {
external: ['quill'],
output: {
inlineDynamicImports: true,
exports: 'named',
globals: {
quill: 'Quill',
},
},
},
},
plugins: [
dts({
insertTypesEntry: true,
}),
{
name: 'copy-bundle',
writeBundle() {
copyFileSync(
resolve(__dirname, 'dist', 'quill-emoji-parser.min.js'),
join(__dirname, 'docs', 'quill-emoji-parser.min.js')
);
/*
this.emitFile({
type: 'asset',
fileName: 'index.html',
source: readFileSync(
resolve(__dirname, 'demo', 'index.html'),
'utf-8'
),
});
*/
},
},
],
});