How would I include the pre-defined moment locales

2019-08-06 19:58发布

问题:

I'm wondering how to include one of the pre-defined momentjs locales in meteor, which normally resides in locales/*.js, but including this per the moment docs does not work in Meteor:

<script src="locale/pt.js"></script>

How would I include the pre-defined moment locales in Meteor?

回答1:

When external resources (javascript libraries, css, images, fonts) are needed, put them in public. So in your case, I would put the file in public/js/momentjs/locales/pt.js. Then, in the file containing my app's <head> (client/head.html in my case):

<head>
  <!-- etc -->
  <script src="/js/momentjs/locales/pt.js"></script>
</head>

All the resources you add in the head will end up being inserted in the head after all the ones from meteor packages, so no need to worry about load order.