I am looking for a way to include momentjs with a localization (german in my case), but not with all other localizations (the 40kb minified version), to keep it slim. Is it possible to exclude all other localizations but one specific?
According to moment.js
docs : Loading locales in the browser just requires you to include the locale files.
<script src="moment.js"></script>
<script src="locale/fr.js"></script>
<script src="locale/pt.js"></script>
<script>
moment.locale('fr'); // Set the default/global locale
// ...
</script>
Also if you desire, you can build a minified moment.js version bundled with the locale of your choice.
grunt embedLocales --embedLocales de
Update:
As mentioned in comments and according to the contribution guide running this command :
grunt transpile:fr,ru
Will result in custom locale bundles moment-with-locales.custom.js
and locales.custom.js
inside build/umd/min
containing just French and Russian.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With