-
-
Notifications
You must be signed in to change notification settings - Fork 35
/
vite.config.js
52 lines (51 loc) · 1.3 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
import fs from 'fs/promises';
import { defineConfig } from 'vite'
import path from 'path'
import react from '@vitejs/plugin-react'
import { NodeGlobalsPolyfillPlugin } from '@esbuild-plugins/node-globals-polyfill'
import { nodePolyfills } from 'vite-plugin-node-polyfills'
export default defineConfig(() => ({
server: {
port: 3000
},
plugins: [
react(),
nodePolyfills(),
],
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
"tinyqueue": path.join(__dirname, 'node_modules', 'tinyqueue', 'index.js')
}
},
build: {
outDir: 'build',
target: 'esnext',
},
define: {
"process.env": process.env ?? {},
},
// We use this configuration to treat .js file as .jsx. In the future we should rename them all
// to .jsx instead and remove this config
esbuild: {
loader: "jsx",
include: /src\/.*\.jsx?$/,
exclude: [],
},
optimizeDeps: {
esbuildOptions: {
plugins: [
NodeGlobalsPolyfillPlugin({ buffer: false, process: true }),
{
name: "load-js-files-as-jsx",
setup(build) {
build.onLoad({ filter: /src\/.*\.js$/ }, async (args) => ({
loader: "jsx",
contents: await fs.readFile(args.path, "utf8"),
}));
},
},
],
},
},
}));