A Vite alternative to Anton Medvedev's @year packages.
Built as an example for a blog post covering virtual modules.
npm i vite-plugin-dates -D
import { dirname } from 'path'
import viteDates from 'vite-plugin-dates'
export default {
root: dirname(new URL(import.meta.url).pathname),
plugins: [viteDates()],
}
import birthday from 'dates:1986/03/05'
document.body.innerHTML = `<p>My birthday is <b>${
new Intl.DateTimeFormat('en', { dateStyle: 'long' }).format(birthday)
}</b>.</p>`
MIT