-
Notifications
You must be signed in to change notification settings - Fork 11
/
vite.config.ts
61 lines (60 loc) · 1.53 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
import { NodeGlobalsPolyfillPlugin } from '@esbuild-plugins/node-globals-polyfill';
import { NodeModulesPolyfillPlugin } from '@esbuild-plugins/node-modules-polyfill';
import rollupNodePolyFill from 'rollup-plugin-node-polyfills';
import { sveltekit } from '@sveltejs/kit/vite';
import { defineConfig } from 'vite';
import { SvelteKitPWA } from '@vite-pwa/sveltekit';
import { nostroidPWA } from './nostroid-config.js';
import inject from '@rollup/plugin-inject';
export default defineConfig({
plugins: [
sveltekit(),
SvelteKitPWA(nostroidPWA),
NodeGlobalsPolyfillPlugin({
process: true,
buffer: true,
webworkers: true
}),
NodeModulesPolyfillPlugin()
],
ssr: {
noExternal: ['nostr-tools']
},
resolve: {
alias: {
process: 'process/browser',
stream: 'rollup-plugin-node-polyfills/polyfills/stream',
util: 'rollup-plugin-node-polyfills/polyfills/util',
buffer: 'rollup-plugin-node-polyfills/polyfills/buffer-es6'
}
},
optimizeDeps: {
include: [
'nostr-tools > create-hash',
'workbox-precaching',
'workbox-routing',
'workbox-window'
],
esbuildOptions: {
// Node.js global to browser globalThis
define: {
global: 'globalThis'
},
plugins: [
NodeGlobalsPolyfillPlugin({
process: true,
buffer: true,
webworkers: true
}),
NodeModulesPolyfillPlugin()
]
}
},
build: {
sourcemap: 'inline', // helpful for debugging, maybe remove in production
rollupOptions: {
plugins: [rollupNodePolyFill(), inject({ Buffer: ['Buffer', 'Buffer'] })]
}
},
define: {}
});