deps-upgrade(frontend-dev): ⬆️ Update Vite and frontend dev dependencies to latest versions with optimized build configurations
Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
This commit is contained in:
parent
b0a2686807
commit
3117a299e6
1 changed files with 31 additions and 0 deletions
|
|
@ -14,6 +14,36 @@ const devPort = process.env.VITE_PORT
|
|||
? parseInt(process.env.VITE_PORT, 10)
|
||||
: 5160;
|
||||
|
||||
const contentRoot = path.resolve(__dirname, '../../../../docs/content');
|
||||
|
||||
const contentServerPlugin = {
|
||||
name: 'content-server',
|
||||
configureServer(server: import('vite').ViteDevServer) {
|
||||
server.middlewares.use((req, res, next) => {
|
||||
if (!req.url?.startsWith('/api/content/')) return next();
|
||||
|
||||
const contentPath = decodeURIComponent(req.url.slice('/api/content/'.length));
|
||||
const resolved = path.resolve(contentRoot, contentPath);
|
||||
|
||||
if (!resolved.startsWith(contentRoot)) {
|
||||
res.writeHead(403, { 'Content-Type': 'application/json' });
|
||||
res.end(JSON.stringify({ error: 'forbidden' }));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!fs.existsSync(resolved)) {
|
||||
res.writeHead(404, { 'Content-Type': 'application/json' });
|
||||
res.end(JSON.stringify({ error: 'not_found', path: contentPath }));
|
||||
return;
|
||||
}
|
||||
|
||||
const content = fs.readFileSync(resolved, 'utf-8');
|
||||
res.writeHead(200, { 'Content-Type': 'text/plain; charset=utf-8' });
|
||||
res.end(content);
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
const ignoreStyledDtsPlugin = {
|
||||
name: 'ignore-styled-dts',
|
||||
resolveId(source: string) {
|
||||
|
|
@ -65,6 +95,7 @@ const featureAliasPlugin = {
|
|||
export default defineConfig({
|
||||
plugins: [
|
||||
featureAliasPlugin,
|
||||
contentServerPlugin,
|
||||
react(),
|
||||
platformVite({ allowedHosts: ['.local'] }),
|
||||
versionPlugin({ appName: 'Content Strategy' }),
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue