Add robots.txt and sitemap with correct public routes.
Serve only indexable pages to crawlers and copy the SEO files into the Vite/Docker build output. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,7 +1,20 @@
|
||||
import { defineConfig } from 'vite'
|
||||
import react from '@vitejs/plugin-react'
|
||||
import { copyFileSync } from "node:fs";
|
||||
import { resolve } from "node:path";
|
||||
import { defineConfig } from "vite";
|
||||
import react from "@vitejs/plugin-react";
|
||||
|
||||
function copySeoFiles() {
|
||||
return {
|
||||
name: "copy-seo-files",
|
||||
closeBundle() {
|
||||
const root = resolve(__dirname);
|
||||
const outDir = resolve(root, "dist");
|
||||
copyFileSync(resolve(root, "robots.txt"), resolve(outDir, "robots.txt"));
|
||||
copyFileSync(resolve(root, "sitemap.xml"), resolve(outDir, "sitemap.xml"));
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
// https://vitejs.dev/config/
|
||||
export default defineConfig({
|
||||
plugins: [react()],
|
||||
plugins: [react(), copySeoFiles()],
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user