@vocab/rollup-plugin
v0.1.6
Published
Copy `translations.json` files into your bundle, preserving directory structure.
Downloads
1,389
Keywords
Readme
@vocab/rollup-plugin
Copy translations.json files into your bundle, preserving directory structure.
Why
translations.json files are never directly referenced by your code, so bundlers typically don't include them in a package bundle.
However, these files are critical for applications that use Vocab with a bundler plugin.
This plugin ensures that they are copied over while maintaining the same directory structure as your source code.
Installation
pnpm install -D @vocab/rollup-pluginUsage
[!IMPORTANT] This plugin will only work if
preserveModules(ortsdown'sunbundle) is set totrue.
// rollup.config.ts
import { vocabTranslations } from '@vocab/rollup-plugin';
export default {
input: './src/index.ts',
output: {
dir: 'dist',
format: 'es',
preserveModules: true
},
plugins: [vocabTranslations({ root: './src' })]
};// tsdown.config.ts
import { defineConfig } from 'tsdown';
import { vocabTranslations } from '@vocab/rollup-plugin';
export default defineConfig({
entry: './src/index.ts',
unbundle: true,
format: 'esm',
plugins: [vocabTranslations({ root: './src' })]
});Options
root (string, required)
The root of the library that all paths are resolved relative to.
Typically this should be the root of your source code, e.g. "./src", not the root of your library.
