admin管理员组

文章数量:1402596

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?

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?

Share Improve this question asked Dec 28, 2014 at 15:40 ClawishClawish 2,9643 gold badges25 silver badges28 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 8

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 ments and according to the contribution guide running this mand :

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.

本文标签: javascriptMomentjs only certain localizationsStack Overflow