How can I add third-party JavaScript libraries to a Meteor application?

后端 未结 4 1909
说谎
说谎 2020-12-01 00:40

I want to add a JavaScript front-end plugin, like jquery.center.js, to a Meteor app.

If I put it in my app/ directory and refresh the page

4条回答
  •  一整个雨季
    2020-12-01 01:19

    Starting with Meteor 1.3, you can add 3rd party JavaScript libraries to a Meteor project directly via their npm package:

    meteor npm install --save moment
    

    Both server-side and client-side package work without modification because Meteor's ES2015 module system takes care of creating a Node-like environment in the client much as browserify or webpack do.

    If an npm package happens to not function correctly, look for a wrapper on Atmoshpere. Atmosphere is Meteor's official 3rd package repository, but less and less relevant after Meteor v1.3. It will eventuall be phased out.

    History

    Before Meteor 1.3, you had to repackage 3rd party libraries for Meteor. A tool called Autopublish was developed to automate the process. After the Meteor Development Group stopped offering free hosting at meteor.com, Autopublish was discontinued.

提交回复
热议问题