问题
According to the Meteor Doc, the public fodler is accessible for both server and client. But, if I just need to use the HTML head elements to access it, how can I do it from server ?
I made a lib with very specific functions, and I'm tired of copy pasting them at the top of each of my server .js file.
Could anyone give me the tip ? I couldn't find out on google :/
Thanks you,
David
回答1:
You are making your life harder than necessary. Any folder that is not called client
, server
, private
, or public
is shared by the client and the server. Just put your shared .js
files into any folder, say, /common
, and they will be available (loaded) on both the client and the server.
The public
folder is specifically for assets that are not loaded automatically by the server, but are instead served statically over HTTP, similar to the static functionality of express. It's the place for images and other assets you want on the client.
来源:https://stackoverflow.com/questions/32099887/meteor-access-to-my-public-lib-from-server