@hejdoktor/vite-plugin-resx
v1.0.0
Published
Helps Vite load compiled versions of resx files
Downloads
52
Readme
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.
