rollup-plugin-app-utils
Table of Contents
Usage:
Output screenshot:
i18nBundler()
Utils
then in your JS import translations using below line
console
Back Filling
i18n bundler reads json files from the specified directory and prepares a JSON structure. It uses base language directory as reference directory and
- Adds missing files, adds missing keys to all the other languages
- Removes keys from other languages JSON files that are removed from base language
- Creates files or remove unnecessary files. For exeample, home.json exists in
en
folder but not inte
folder, then when you build, the i18nBundler will create file and copy the content from base language folder for you. In a same way, ifte
folder containstest.json
buten
folder does not, thentest.json
will be removed from thete
folder
For example, if you have locales folder with this structure and content,
it will be transformed to below:
Please check test-data
folder for example structure. Then run npm test
and take a look at test-data-copy/output.js
and test-data-copy/locales
for a better understanding.
copyAssets()
Helps to copy static content from during build, this does the job in a synchronous way.
Utils // uses fs-extra `copySync`. You can also pass filter function
prepareDirectories()
Helps to prepare directories during build, this does the job in a synchronous way. For example, during thee build if you want to use dynamically named folder name, this method can be used to create directories. We use this to create a folder with unique name and then put static content in it.
Utils // or Utils
emptyDirectories()
Helps to cleanup directories during build, this does the job in a synchronous way. We use this to clean the dist folder before rollup write the output to dist folder.
Utils // or Utils
htmlInjector()
Helps to generate a html page from template and write to a target html file. This does the job in a synchronous way.
For example you have below html:
{title} {keyOne}
Then in your rollup config if you do below:
Utils
The output looks like this:
___title___ ___keyOne____
Contributing:
Please check guidelines for more details.