-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
77 lines (76 loc) · 3.15 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
67
68
69
70
71
72
73
74
75
76
77
import { fileURLToPath, URL } from 'node:url';
import { NodeGlobalsPolyfillPlugin } from '@esbuild-plugins/node-globals-polyfill';
import { NodeModulesPolyfillPlugin } from '@esbuild-plugins/node-modules-polyfill';
import vue from '@vitejs/plugin-vue';
import rollupNodePolyFill from 'rollup-plugin-node-polyfills';
import { visualizer } from 'rollup-plugin-visualizer';
import { defineConfig, splitVendorChunkPlugin, type UserConfig } from 'vite';
export default defineConfig({
base: './',
plugins: [vue(), visualizer({ gzipSize: true }), splitVendorChunkPlugin()],
server: {
port: 8080,
},
resolve: {
alias: {
'@': fileURLToPath(new URL('src', import.meta.url)),
_stream_duplex: 'rollup-plugin-node-polyfills/polyfills/readable-stream/duplex',
_stream_passthrough: 'rollup-plugin-node-polyfills/polyfills/readable-stream/passthrough',
_stream_readable: 'rollup-plugin-node-polyfills/polyfills/readable-stream/readable',
_stream_transform: 'rollup-plugin-node-polyfills/polyfills/readable-stream/transform',
_stream_writable: 'rollup-plugin-node-polyfills/polyfills/readable-stream/writable',
assert: 'rollup-plugin-node-polyfills/polyfills/assert',
console: 'rollup-plugin-node-polyfills/polyfills/console',
constants: 'rollup-plugin-node-polyfills/polyfills/constants',
domain: 'rollup-plugin-node-polyfills/polyfills/domain',
events: 'rollup-plugin-node-polyfills/polyfills/events',
http: 'rollup-plugin-node-polyfills/polyfills/http',
https: 'rollup-plugin-node-polyfills/polyfills/http',
os: 'rollup-plugin-node-polyfills/polyfills/os',
path: 'rollup-plugin-node-polyfills/polyfills/path',
punycode: 'rollup-plugin-node-polyfills/polyfills/punycode',
querystring: 'rollup-plugin-node-polyfills/polyfills/qs',
stream: 'rollup-plugin-node-polyfills/polyfills/stream',
string_decoder: 'rollup-plugin-node-polyfills/polyfills/string-decoder',
sys: 'util',
timers: 'rollup-plugin-node-polyfills/polyfills/timers',
tty: 'rollup-plugin-node-polyfills/polyfills/tty',
url: 'rollup-plugin-node-polyfills/polyfills/url',
util: 'rollup-plugin-node-polyfills/polyfills/util',
vm: 'rollup-plugin-node-polyfills/polyfills/vm',
zlib: 'rollup-plugin-node-polyfills/polyfills/zlib',
buffer: 'rollup-plugin-node-polyfills/polyfills/buffer-es6',
process: 'rollup-plugin-node-polyfills/polyfills/process-es6',
},
},
optimizeDeps: {
esbuildOptions: {
define: {
global: 'globalThis',
},
plugins: [
NodeGlobalsPolyfillPlugin({
buffer: true,
process: true,
}),
NodeModulesPolyfillPlugin(),
],
},
},
esbuild: {
pure: ['console.log'],
drop: ['debugger'],
},
build: {
rollupOptions: {
plugins: [rollupNodePolyFill()],
output: {
chunkFileNames: 'chunks/[name]-[hash].js',
manualChunks: filepath => {
if (filepath.includes('compiler-sfc.esm-browser')) return 'compiler-sfc-esm-browser';
if (filepath.includes('@fortawesome')) return '@fortawesome';
},
},
},
},
}) as UserConfig;