@hejdoktor/vite-plugin-resx
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

vite-plugin-resx

Helps Vite compile and resolve resx files.

Setting up Vite

A minimal vite.config.js file enabling only this resolver should look like the following:

import { resx } from "@hejdoktor/vite-plugin-resx"

export default defineConfig({
    plugins: [resx({ buildCommand: "npm run resx" })],
})

The buildCommand passed in will be executed when a change in a .resx file is detected, and should do the actual transformation.

The example buildCommand is defined as following in the parent projects package.json, using @hejdoktor/resx-compiler.

{
  "scripts": {
    "resx": "resx-compiler --default-locale en Client --pluralize"
  },
  "devDependencies": {
    "@hejdoktor/resx-compiler": "^0.4.0"
  }
}

Usage in code

The point of this resolver is to enable the following code:

import { R } from "./some-translations.resx"

console.log(R.someTranslatedFile)

Without this plugin, Vite will attempt to load some-translations.resx file as javascript. With this plugin, Vite will return some-translations.resx.ts, which should be a compiled version of the translation file, instead.

Readme

Keywords

Package Sidebar

Install

npm i @hejdoktor/vite-plugin-resx

Weekly Downloads

20

Version

1.0.0

License

ISC

Unpacked Size

5.07 kB

Total Files

4

Last publish

Collaborators

  • fizker