- nginx: try_files adds $uri.html so /dev-doc, /simple-doc, /review-doc resolve to the flat .html files before the SPA fallback (prod). - vite: dev-only middleware mirrors the same rewrite so the clean URLs work under `vite dev` too (no SPA-fallback / router warning). - simple-doc: add hex values inline + a "Quick reference (for the developer)" swatch grid (full palette + category colours) and type/ button/divider specs — kept layman. Cross-links now use /dev-doc. dist/ rebuilt. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
37 lines
1.1 KiB
JavaScript
37 lines
1.1 KiB
JavaScript
import { defineConfig } from 'vite'
|
|
import vue from '@vitejs/plugin-vue'
|
|
import tailwindcss from '@tailwindcss/vite'
|
|
import { fileURLToPath, URL } from 'node:url'
|
|
|
|
// Static handoff docs live as flat files in public/ (dev-doc.html etc.).
|
|
// In production nginx rewrites the extensionless path to <name>.html
|
|
// (try_files $uri $uri.html …). This dev-only middleware mirrors that so
|
|
// the same clean URLs (/dev-doc, /simple-doc, /review-doc) work under
|
|
// `vite dev` instead of being swallowed by the SPA history fallback.
|
|
const DOC_SLUGS = ['dev-doc', 'simple-doc', 'review-doc']
|
|
function cleanDocUrls() {
|
|
return {
|
|
name: 'clean-doc-urls',
|
|
configureServer(server) {
|
|
server.middlewares.use((req, _res, next) => {
|
|
const path = (req.url || '').split('?')[0].replace(/\/+$/, '')
|
|
const slug = path.replace(/^\/+/, '')
|
|
if (DOC_SLUGS.includes(slug)) req.url = `/${slug}.html`
|
|
next()
|
|
})
|
|
},
|
|
}
|
|
}
|
|
|
|
export default defineConfig({
|
|
plugins: [cleanDocUrls(), vue(), tailwindcss()],
|
|
resolve: {
|
|
alias: {
|
|
'@': fileURLToPath(new URL('./src', import.meta.url)),
|
|
},
|
|
},
|
|
server: {
|
|
port: 5173,
|
|
},
|
|
})
|