-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathvite.config.js
More file actions
85 lines (78 loc) · 2.38 KB
/
vite.config.js
File metadata and controls
85 lines (78 loc) · 2.38 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import { defineConfig } from 'vite';
import { resolve } from 'path';
import { fileURLToPath } from 'url';
import { readFileSync } from 'fs';
import banner from 'vite-plugin-banner';
import { nodePolyfills } from 'vite-plugin-node-polyfills';
import { ejsPrecompile } from './vite-plugin-ejs-precompile.js';
const __dirname = fileURLToPath(new URL('.', import.meta.url));
const PACKAGE = JSON.parse(
readFileSync(new URL('./package.json', import.meta.url), 'utf8')
);
const bannerText = `${PACKAGE.name} - ${PACKAGE.version} | (c) 2018 ${PACKAGE.author} | ${PACKAGE.license} | ${PACKAGE.homepage}`;
export default defineConfig({
build: {
lib: {
entry: resolve(__dirname, 'src/jepub.js'),
name: 'jEpub',
formats: ['umd', 'es'],
fileName: (format) =>
format === 'umd' ? 'jepub.js' : `jepub.${format}.js`,
},
rollupOptions: {
external: ['jszip'],
output: {
globals: {
jszip: 'JSZip',
},
},
onwarn(warning, warn) {
// Suppress Node.js module warnings for browser build
if (
warning.code === 'MISSING_NODE_BUILTINS' ||
warning.code === 'UNRESOLVED_IMPORT'
) {
return;
}
// Suppress eval warnings from file-type package (dependency of image-type)
if (
warning.message &&
warning.message.includes('Use of eval')
) {
return;
}
warn(warning);
},
},
outDir: 'dist',
emptyOutDir: true,
sourcemap: true,
minify: 'terser',
terserOptions: {
compress: {
drop_console: true,
},
},
},
resolve: {
alias: {
'@': resolve(__dirname, 'src'),
},
},
plugins: [
ejsPrecompile(),
banner(bannerText),
nodePolyfills({
include: [], // Minimal polyfills
globals: {
Buffer: false,
global: false,
process: false,
},
protocolImports: true,
}),
],
optimizeDeps: {
include: ['jszip', '@xmldom/xmldom'],
},
});