-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
64 lines (63 loc) · 1.43 KB
/
vite.config.ts
File metadata and controls
64 lines (63 loc) · 1.43 KB
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
import { defineConfig } from 'vite';
import path from 'path';
import cssInjectedByJsPlugin from 'vite-plugin-css-injected-by-js';
import terser from '@rollup/plugin-terser';
export default defineConfig({
plugins: [cssInjectedByJsPlugin()],
resolve: {
alias: {
'textmode.export.js': path.resolve(__dirname, 'src/index.ts'),
},
},
server: {
open: '/examples/index.html',
},
build: {
minify: 'esbuild',
lib: {
entry: 'src/index.ts',
name: 'TextmodeExport',
fileName: (format) => `textmode.export.${format === 'es' ? 'esm' : format}.js`,
formats: ['es', 'umd'],
},
rollupOptions: {
plugins: [
terser({
compress: {
drop_debugger: true,
ecma: 2020,
// Disable toplevel for UMD compatibility
toplevel: false,
// Reduce unsafe optimizations for UMD
unsafe: false,
global_defs: {
IS_MINIFIED: true,
},
},
mangle: {
toplevel: false,
// Disable property mangling for UMD builds to avoid syntax errors
properties: false,
reserved: ['TextmodeExport'],
},
format: {
comments: false,
ecma: 2020,
},
// Module mode only works reliably with ESM, not UMD
module: false,
}),
],
// Make sure to externalize deps that shouldn't be bundled
external: ['textmode.js'],
output: {
globals: {
'textmode.js': 'textmode',
},
},
treeshake: {
preset: 'smallest',
},
},
},
});