0.0.1 • Published 3 years ago

vite-plugin-dates v0.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

vite-plugin-dates

A Vite alternative to Anton Medvedev's @year packages.

Built as an example for a blog post covering virtual modules.

Install

npm i vite-plugin-dates -D

Configuration

import { dirname } from 'path'
import viteDates from 'vite-plugin-dates'

export default {
  root: dirname(new URL(import.meta.url).pathname),
  plugins: [viteDates()],
}

Usage

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>`

License

MIT