mirror of
https://github.com/tale/headplane.git
synced 2026-08-31 01:09:25 +00:00
feat: use all native node deps for the server
This commit is contained in:
+55
-18
@@ -6,22 +6,59 @@ import tsconfigPaths from 'vite-tsconfig-paths'
|
||||
|
||||
installGlobals()
|
||||
|
||||
export default defineConfig(({ isSsrBuild }) => ({
|
||||
base: '/admin/',
|
||||
build: isSsrBuild ? { target: 'ES2022' } : {},
|
||||
plugins: [
|
||||
remix({
|
||||
basename: '/admin/',
|
||||
}),
|
||||
tsconfigPaths(),
|
||||
babel({
|
||||
filter: /\.[jt]sx?$/,
|
||||
babelConfig: {
|
||||
presets: ['@babel/preset-typescript'],
|
||||
plugins: [
|
||||
['babel-plugin-react-compiler', {}],
|
||||
],
|
||||
const prefix = process.env.__INTERNAL_PREFIX || '/admin/'
|
||||
if (!prefix.endsWith('/')) {
|
||||
throw new Error('Prefix must 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')) {
|
||||
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', {}],
|
||||
],
|
||||
},
|
||||
}),
|
||||
],
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user