-
Notifications
You must be signed in to change notification settings - Fork 7
/
vite.config.js
56 lines (52 loc) · 1.46 KB
/
vite.config.js
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
import { createLogger, defineConfig } from 'vite'
import { sveltekit } from '@sveltejs/kit/vite'
import { readFileSync } from 'fs'
import { fileURLToPath } from 'url'
import basicSsl from '@vitejs/plugin-basic-ssl'
import { NodeGlobalsPolyfillPlugin } from '@esbuild-plugins/node-globals-polyfill'
import rollupNodePolyFill from 'rollup-plugin-polyfill-node'
const file = fileURLToPath(new URL('package.json', import.meta.url))
const json = readFileSync(file, 'utf8')
const pkg = JSON.parse(json)
const logger = createLogger()
const loggerError = logger.error
logger.error = (msg, options) => {
// Ignore empty CSS files warning
if (msg.includes('window is not defined')) return
loggerError(msg, options)
}
export default ({ mode }) =>
defineConfig({
plugins: [sveltekit(), ...(mode === 'https' ? [basicSsl()] : [])],
customLogger: logger,
define: {
__APP_VERSION__: JSON.stringify(pkg.version)
},
build: {
rollupOptions: {
plugins: [rollupNodePolyFill()]
},
target: 'esnext'
},
worker: {
plugins: [sveltekit()],
format: 'es'
},
optimizeDeps: {
esbuildOptions: {
// Node.js global to browser globalThis
define: {
global: 'globalThis'
},
// Enable esbuild polyfill plugins
plugins: [
NodeGlobalsPolyfillPlugin({
buffer: true
})
],
supported: {
bigint: true
}
}
}
})