Can I choose which locales are loaded? #852
-
We have limited CI time in our project and I would like to reduce the time where our prod build is deployed so I am investigating now which files are not necessary. I saw that this lib has a lot of translation files which in our case are not all needed. We would just need en, de and fr locales. Is there a way to declare which locales are used so not all are build into the dist folder? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
Yes, you can do that. The documentation suggests to copy the entire assets folder, but most of the time, you only need a small fraction of the files. You can configure the
You can even get rid of the entire folder if you inline the translation files. That's what the folder The advantage of this approach is that ngx-extended-pdf-viewer uses two requests less. In other words, it's faster. The disadvantage is you need to update the HTML snippets when you update ngx-extended-pdf-viewer. Currently, the base library updates roughly four times a year, so you end up updating the HTML snippets four times a year, too. On the other hands, the translation files are pretty stable, so you can skip an update every once in a while. |
Beta Was this translation helpful? Give feedback.
-
Copy-and-paste {
"input": "node_modules/ngx-extended-pdf-viewer/assets/",
// Adjust your locales here but do not remove "locale" because it is required
"glob": "**/{locale,de,en-GB,fr,ru,es-ES}/?*.properties",
"ignore": ["**/additional-locale/*"],
"output": "./assets/"
},
{
"input": "node_modules/ngx-extended-pdf-viewer/assets/",
"glob": "**/*.min.js",
"ignore": ["*-es5\\.*"],
"output": "./assets/"
} ComparisonInclude everything
Exclude unnecessary
I guess the extra 10 seconds of build time come from the path regex, but this is totally fine for that bundle size reduction. |
Beta Was this translation helpful? Give feedback.
Yes, you can do that. The documentation suggests to copy the entire assets folder, but most of the time, you only need a small fraction of the files. You can configure the
architect -> build -> options -> assets
section of yourangular.json
like so:cmaps
. You only need it to display old East-Asian files.additional-locales
shouldn't even be part of the distribution. Omit it.inline-locale-file
isn't used by the PDF viewer. Get rid of it. I'll talk about it again in a minute.locale
of the languages you need. Drop everything else.You can even get rid of the entire folder if you inline the…