Skip to content

blissful-group/vite-plugin-import-intl

Repository files navigation

vite-plugin-import-intl

A simple intl globbing import package for Vite

Build Status Code Coverage Issues Open Licenses Bundle Size NPM

Getting started

Install package

npm install -D vite-plugin-import-intl
yarn add -D vite-plugin-import-intl
pnpm add -D vite-plugin-import-intl

Add plugin to vite.config

// vite.config.ts
import importIntl from 'vite-plugin-import-intl'

export default defineConfig({
  plugins: [
    ...,
    importIntl(),
  ],
  ...
})

Add types to tsconfig.json (this provides import.meta.intl intellisense)

// tsconfig.json
{
  "compilerOptions": {
    "types": ["vite-plugin-import-intl/client"],
    ...
  },
}

Usage

To use the plugin, just import a glob of a certain folder, file or array of said locations

// Example
const locales = import.meta.intl('./*.json') // All json files in current folder
const locales = import.meta.intl(['../intl', '../other/intl']) // All json files in the intl and other/intl folder one directory up

About

Simple globbing import package for Vite

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published

Contributors 3

  •  
  •  
  •