Skip to content

galvez/vite-plugin-dates

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Dynamically import date objects as virtual modules

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published