76 lines
1.4 KiB
JavaScript
76 lines
1.4 KiB
JavaScript
import {readFileSync} from 'node:fs';
|
|
import {fileURLToPath} from 'node:url';
|
|
|
|
import {vitePlugin as remix} from '@remix-run/dev';
|
|
import react from '@vitejs/plugin-react';
|
|
import sylvite from 'sylvite';
|
|
import {defineConfig} from 'vite';
|
|
|
|
import environment from './environment.server.js';
|
|
|
|
const {
|
|
httpsCert,
|
|
httpsKey,
|
|
isInsecure,
|
|
} = environment();
|
|
|
|
const {hooks} = await sylvite({
|
|
...await import('./sylvite.config.js'),
|
|
});
|
|
|
|
const plugins = [];
|
|
|
|
if (!process.env.REMIX_DISABLED) {
|
|
plugins.push(
|
|
remix({
|
|
future: {
|
|
v3_fetcherPersist: true,
|
|
v3_relativeSplatPath: true,
|
|
v3_throwAbortReason: true,
|
|
unstable_singleFetch: true,
|
|
unstable_lazyRouteDiscovery: true,
|
|
},
|
|
routes(defineRoutes) {
|
|
return defineRoutes((route) => {
|
|
hooks.call('./sylvite/remix:defineRemixRoutes', route);
|
|
});
|
|
},
|
|
}),
|
|
);
|
|
}
|
|
else {
|
|
plugins.push(react());
|
|
}
|
|
|
|
export default defineConfig(hooks.call('sylvite:viteConfig', {
|
|
esbuild: {
|
|
supported: {
|
|
'top-level-await': true,
|
|
},
|
|
},
|
|
plugins,
|
|
resolve: {
|
|
alias: [
|
|
{
|
|
find: '@',
|
|
replacement: fileURLToPath(new URL('./app', import.meta.url)),
|
|
},
|
|
],
|
|
},
|
|
server: {
|
|
host: true,
|
|
hmr: {
|
|
port: 3101,
|
|
},
|
|
...(!isInsecure && {
|
|
https: {
|
|
key: readFileSync(httpsKey),
|
|
cert: readFileSync(httpsCert),
|
|
},
|
|
}),
|
|
},
|
|
worker: {
|
|
format: 'es',
|
|
},
|
|
}));
|