forked from jeffeb3/sandify
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.js
More file actions
55 lines (54 loc) · 1.54 KB
/
Copy pathvite.config.js
File metadata and controls
55 lines (54 loc) · 1.54 KB
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
import fs from 'fs/promises';
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import { NodeGlobalsPolyfillPlugin } from '@esbuild-plugins/node-globals-polyfill'
import nodePolyfills from 'rollup-plugin-node-polyfills'
export default defineConfig(() => ({
server: {
port: 3000
},
plugins: [react()],
resolve: {
alias: {
process: "rollup-plugin-node-polyfills/polyfills/process-es6",
timers: "rollup-plugin-node-polyfills/polyfills/timers",
stream: "rollup-plugin-node-polyfills/polyfills/stream",
events: "rollup-plugin-node-polyfills/polyfills/events",
util: "rollup-plugin-node-polyfills/polyfills/util",
buffer: "rollup-plugin-node-polyfills/polyfills/buffer-es6"
}
},
build: {
outDir: 'build',
target: 'esnext',
rollupOptions: {
plugins: [nodePolyfills()],
}
},
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: 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"),
}));
},
},
],
},
},
}));