-
Notifications
You must be signed in to change notification settings - Fork 13
/
vite.config.ts
64 lines (60 loc) · 1.47 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
62
63
64
import { vitePlugin as remix } from '@remix-run/dev'
import { installGlobals } from '@remix-run/node'
import { defineConfig } from 'vite'
import babel from 'vite-plugin-babel'
import tsconfigPaths from 'vite-tsconfig-paths'
installGlobals()
const prefix = process.env.__INTERNAL_PREFIX || '/admin'
if (prefix.endsWith('/')) {
throw new Error('Prefix must not end with a slash')
}
export default defineConfig(({ isSsrBuild }) => {
// If we have the Headplane entry we build it as a single
// server.mjs file that is built for production server bundle
// We know the remix invoked command is vite:build
if (!process.argv.includes('vite:build') && !process.argv.includes('vite:dev')) {
return {
build: {
minify: false,
target: 'esnext',
rollupOptions: {
input: './server.mjs',
output: {
entryFileNames: 'server.js',
dir: 'build/headplane',
banner: '#!/usr/bin/env node\n',
},
external: (id) => id.startsWith('node:'),
}
},
define: {
PREFIX: JSON.stringify(prefix),
},
resolve: {
alias: {
stream: 'node:stream',
crypto: 'node:crypto',
}
}
}
}
return ({
base: `${prefix}/`,
build: isSsrBuild ? { target: 'ES2022' } : {},
plugins: [
remix({
basename: `${prefix}/`,
}),
tsconfigPaths(),
babel({
filter: /\.[jt]sx?$/,
babelConfig: {
presets: ['@babel/preset-typescript'],
plugins: [
['babel-plugin-react-compiler', {}],
],
},
}),
],
})
})