mirror of
https://github.com/tale/headplane.git
synced 2026-09-04 11:15:42 +00:00
chore: switch to react-router v7
This commit is contained in:
+23
-33
@@ -1,18 +1,18 @@
|
||||
import { vitePlugin as remix } from '@remix-run/dev'
|
||||
import { defineConfig } from 'vite'
|
||||
import babel from 'vite-plugin-babel'
|
||||
import tsconfigPaths from 'vite-tsconfig-paths'
|
||||
import { execSync } from 'node:child_process'
|
||||
import { reactRouter } from '@react-router/dev/vite';
|
||||
import { defineConfig } from 'vite';
|
||||
import babel from 'vite-plugin-babel';
|
||||
import tsconfigPaths from 'vite-tsconfig-paths';
|
||||
import { execSync } from 'node:child_process';
|
||||
|
||||
const prefix = process.env.__INTERNAL_PREFIX || '/admin'
|
||||
const prefix = process.env.__INTERNAL_PREFIX || '/admin';
|
||||
if (prefix.endsWith('/')) {
|
||||
throw new Error('Prefix must not end with a slash')
|
||||
throw new Error('Prefix must not end with a slash');
|
||||
}
|
||||
|
||||
// Load the version via git tags
|
||||
const version = execSync('git describe --tags --always').toString().trim()
|
||||
const version = execSync('git describe --tags --always').toString().trim();
|
||||
if (!version) {
|
||||
throw new Error('Unable to execute git describe')
|
||||
throw new Error('Unable to execute git describe');
|
||||
}
|
||||
|
||||
export default defineConfig(({ isSsrBuild }) => {
|
||||
@@ -20,8 +20,8 @@ export default defineConfig(({ isSsrBuild }) => {
|
||||
// server/prod.mjs file that is built for production server bundle
|
||||
// We know the remix invoked command is vite:build
|
||||
if (
|
||||
process.env.NODE_ENV !== 'development'
|
||||
&& !process.argv.includes('vite:build')
|
||||
process.env.NODE_ENV !== 'development' &&
|
||||
!process.argv.includes('vite:build')
|
||||
) {
|
||||
return {
|
||||
build: {
|
||||
@@ -35,7 +35,7 @@ export default defineConfig(({ isSsrBuild }) => {
|
||||
banner: '#!/usr/bin/env node\n',
|
||||
},
|
||||
external: (id) => id.startsWith('node:'),
|
||||
}
|
||||
},
|
||||
},
|
||||
define: {
|
||||
PREFIX: JSON.stringify(prefix),
|
||||
@@ -44,39 +44,29 @@ export default defineConfig(({ isSsrBuild }) => {
|
||||
alias: {
|
||||
stream: 'node:stream',
|
||||
crypto: 'node:crypto',
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
return ({
|
||||
base: `${prefix}/`,
|
||||
return {
|
||||
base: prefix,
|
||||
build: isSsrBuild ? { target: 'ES2022' } : {},
|
||||
|
||||
define: {
|
||||
__VERSION__: JSON.stringify(version),
|
||||
},
|
||||
|
||||
plugins: [
|
||||
remix({
|
||||
basename: `${prefix}/`,
|
||||
future: {
|
||||
v3_fetcherPersist: true,
|
||||
v3_relativeSplatPath: true,
|
||||
v3_throwAbortReason: true,
|
||||
v3_lazyRouteDiscovery: true,
|
||||
v3_singleFetch: true,
|
||||
v3_routeConfig: true
|
||||
},
|
||||
}),
|
||||
reactRouter(),
|
||||
tsconfigPaths(),
|
||||
babel({
|
||||
filter: /\.[jt]sx?$/,
|
||||
babelConfig: {
|
||||
presets: ['@babel/preset-typescript'],
|
||||
plugins: [
|
||||
['babel-plugin-react-compiler', {}],
|
||||
],
|
||||
plugins: [['babel-plugin-react-compiler', {}]],
|
||||
},
|
||||
}),
|
||||
],
|
||||
})
|
||||
})
|
||||
};
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user