mirror of
https://github.com/hanzoai/vite.git
synced 2026-10-30 19:36:16 +00:00
27 lines
679 B
TypeScript
27 lines
679 B
TypeScript
import path from 'node:path'
|
|
import { type Plugin, normalizePath } from 'vite'
|
|
|
|
// use plugin to simulate server rendered css link
|
|
export function TestCssLinkPlugin(): Plugin {
|
|
return {
|
|
name: 'test-css-link',
|
|
transformIndexHtml: {
|
|
handler(_html, ctx) {
|
|
if (!ctx.filename.endsWith('/css-link/index.html')) return
|
|
return [
|
|
{
|
|
tag: 'link',
|
|
attrs: {
|
|
rel: 'stylesheet',
|
|
href: '/css-link/styles.css',
|
|
'data-vite-dev-id': normalizePath(
|
|
path.resolve(import.meta.dirname, 'styles.css'),
|
|
),
|
|
},
|
|
},
|
|
]
|
|
},
|
|
},
|
|
}
|
|
}
|