fix: separate vite builds for server and framework

This commit is contained in:
Aarnav Tale 2025-01-06 08:14:18 +05:30
parent 7217659720
commit 414b95c293
No known key found for this signature in database
6 changed files with 305 additions and 169 deletions

View file

@ -3,6 +3,8 @@ import { defineConfig } from 'vite';
import babel from 'vite-plugin-babel';
import tsconfigPaths from 'vite-tsconfig-paths';
import { execSync } from 'node:child_process';
import tailwindcss from 'tailwindcss';
import autoprefixer from 'autoprefixer';
const prefix = process.env.__INTERNAL_PREFIX || '/admin';
if (prefix.endsWith('/')) {
@ -15,29 +17,15 @@ if (!version) {
throw new Error('Unable to execute git describe');
}
export default defineConfig(({ isSsrBuild }) => {
// If we have the Headplane entry we build it as a single
// server/prod.mjs file that is built for production server bundle
// We know the remix invoked command is vite:build
return {
base: prefix,
build: isSsrBuild ? { target: 'ES2022' } : {},
define: {
__VERSION__: JSON.stringify(version),
export default defineConfig({
base: `${prefix}/`,
plugins: [reactRouter(), tsconfigPaths()],
css: {
postcss: {
plugins: [tailwindcss, autoprefixer],
},
plugins: [
reactRouter(),
tsconfigPaths(),
babel({
filter: /\.[jt]sx?$/,
babelConfig: {
presets: ['@babel/preset-typescript'],
plugins: [['babel-plugin-react-compiler', {}]],
},
}),
],
};
},
define: {
__VERSION__: JSON.stringify(version),
},
});