I'm creating a package and, for the client side, I need to add some static files like fonts and images. After trying some outdated solution I found nothing seemed to work for me. How should I add those files? Create a public folder inside my package? Adding the files with api.addFiles
?
Is this even possible?
相关问题
- A good way to define default rendering templates i
- How to integrate meteor's velocity tests with
- Installing Cordova plugin to meteor project using
- Using tinytest to test Meteor client while the ser
- Django DDP assistance
相关文章
- External dependencies (like bootstrap) in Meteor
- how to properly configure meteor to work with node
- Can meteor mongo driver handle $each and $position
- Meteor blocking clarification
- Setting the “Content-Type” header in HTTP.call on
- Log in to a meteor app from a Google chrome extens
- Meteor collection.insert callback to return new id
- how can I set a callback for the user session time
For assets file like favicon.ico or fonts files you can create a
public
folder.You can check this answer or the documentation.
update: meteor 1.2
You should now use api.addAssets to add static files to your package.
original answer
You can add static assets to any package and they will be served by meteor. The easiest way to demonstrate this is with an example. Have a look at the source for hopscotch.
The package contains an
img
directory with the filesprite-green-0.3.png
. If you look at thepackage.js
file you can see that it gets added to the client with:After adding the package to your project, you can access the file directly with this URL:
In summary, you can use api.addFiles to add static assets. All assets will be accessable under a path like
/packages/[package name]/[path to asset]
.Note that you can add
{isAsset: true}
as a third argument toaddFiles
for assets which should not be automatically loaded. This post contains an example of its use.