Bads
Bads

Reputation: 774

Meteor Package add global asset

To add an asset from meteor package what you need to do is:

api.add_files(['s.json'], 'server', {isAsset: true});

Now you can call this asset by

Assets.getText("s.json");

But the problem is this only works in the package the asset is added to.

Is there a way to add asset so that you can get this asset from other package as well?

Thanks.

Upvotes: 3

Views: 1273

Answers (1)

Tarang
Tarang

Reputation: 75955

You need to export the asset text:

In a file (somefile.js)

AssetData = Assets.getText("s.json");

in your package.js

api.add_files(['some.js', 'files.json'], 'server');
api.export("AssetData", ["server"]);

Then in your other package

package.js

api.use("<name of other package>");

Then you can use AssetData anywhere in that package on the server side.

Upvotes: 9

Related Questions