fix:提交更新
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
/**
|
||||
* After vite build: copy dist/index.html to each main route folder for crawler/static hosting.
|
||||
*/
|
||||
import fs from 'node:fs'
|
||||
import path from 'node:path'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
||||
const outDir = path.resolve(__dirname, '../dist')
|
||||
|
||||
const ROUTES = [
|
||||
'/brand',
|
||||
'/poetry',
|
||||
'/qingxiang',
|
||||
'/haoke',
|
||||
'/system',
|
||||
'/tech',
|
||||
'/subsidy',
|
||||
'/partner',
|
||||
'/tech-detail',
|
||||
'/contact',
|
||||
]
|
||||
|
||||
const indexHtml = path.join(outDir, 'index.html')
|
||||
if (!fs.existsSync(indexHtml)) {
|
||||
console.error('dist/index.html not found; run vite build first')
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
const html = fs.readFileSync(indexHtml, 'utf8')
|
||||
for (const route of ROUTES) {
|
||||
const dir = path.join(outDir, route.replace(/^\//, ''))
|
||||
fs.mkdirSync(dir, { recursive: true })
|
||||
fs.writeFileSync(path.join(dir, 'index.html'), html)
|
||||
console.log(`prerender ${route}/index.html`)
|
||||
}
|
||||
console.log('Done.')
|
||||
Reference in New Issue
Block a user