vite-plugin-import-intl
TypeScript icon, indicating that this package has built-in type declarations

2.0.0 • Public • Published

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

Readme

Keywords

Package Sidebar

Install

npm i vite-plugin-import-intl

Weekly Downloads

2

Version

2.0.0

License

MIT

Unpacked Size

17.2 kB

Total Files

11

Last publish

Collaborators

  • blissful89