-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvite.config.main.ts
69 lines (64 loc) · 2.02 KB
/
vite.config.main.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
import { fileURLToPath, URL } from 'node:url'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { VitePWA } from 'vite-plugin-pwa'
import { NodeGlobalsPolyfillPlugin } from '@esbuild-plugins/node-globals-polyfill'
import { NodeModulesPolyfillPlugin } from '@esbuild-plugins/node-modules-polyfill'
import rollupNodePolyFill from 'rollup-plugin-node-polyfills'
import inject from '@rollup/plugin-inject';
// https://vitejs.dev/config/
export default defineConfig({
define: {
global: 'window',
},
plugins: [
vue({
template: {
compilerOptions: {
// treat any tag that starts with rdf- as custom elements
isCustomElement: tag => tag.startsWith('rdf-')
}
}
}),
VitePWA({
registerType: 'autoUpdate',
filename: 'service-worker.js',
workbox: {
maximumFileSizeToCacheInBytes: 5 * 1024 ** 2, // 5 MB or set to something else
globPatterns: ['**/*.{js,css,html,woff,woff2,svg,webmanifest,ico,png}'],
}
}),
],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url)),
stream: 'readable-stream',
util: 'util',
}
},
optimizeDeps: {
esbuildOptions: {
plugins: [
NodeGlobalsPolyfillPlugin({
process: true,
buffer: true,
}) as any,
NodeModulesPolyfillPlugin()
],
},
},
build: {
rollupOptions: {
plugins: [
rollupNodePolyFill() as any,
inject({
process: 'process', // Inject process global
Buffer: ['buffer', 'Buffer'], // Inject Buffer global
}),
],
input: {
main: fileURLToPath(new URL('./index.html', import.meta.url))
}
},
},
})