Package addFiles with a specific folder name


I am attempting to create a package that needs to copy assets into the ‘public’ directory when adding the package to a project.

According to the meteor documentation regarding api.addFiles the allowed values for architecture are

  • ‘server’
  • ‘client’
  • ‘web.browser’
  • ‘web.cordova’

I need to be able to add files into a specific directory, e.g.

api.addFiles('main.css', 'public/css');
api.addFiles('main-rtl.css', 'public/css');

I am not able to load both CSS files on the client, as depending on which orientation the user selects either one or the other CSS are used, not both. There are a huge number of differences between both CSS files, so it is not feasible to use template helpers to change the HTML depending on the selected orientation.

Is what I describe above doable, specifying a specific folder in which to copy the files I need?


Rudolf Bargholz

Anything you add to the client is available at the URL /packages/AUTHOR_PACKAGENAME/path/you/added. So if your package name was author:package and you added some css files like this,

api.addFiles(['css/file1.css', 'css/file2.css'], 'client');

They are available at the URL, /packages/author_package/css/fileX.css. Does that make sense?

Hi @jchristman,

Thanks for the advice.

I was under the impression, that if I supplied client as the architecture, then Meteor would automatically merge all Javascript and CSS files when deploying to production. Is this correct, or is my impression wrong? If correct, then by combining all CSS files into one file, both the normal and Right-to-Left CSS files will both be loaded in the browser, which is what I would like to avoid.

I found the following:

David in his example uses the following for adding assets:

api.addFiles('companions/martha.json', 'server', {isAsset: true});

Could the {isAsset: true} prevent the combining and minifying of the CSS files and prevent these from being loaded into the browser by default? I have not been able to find documentation regarding isAsset, but perhaps this might be the way to go.

Again, thanks for your help. I was not aware of this option.


Rudolf Bargholz

Reading the comments on this answer, @mizzao says that “you should use {isAsset: true} for CSS and JS files that you don’t want auto-loaded on the client.” Then you can access them as shown above on the client if you want.

Hi @jchristman,

Thanks. I think this is exactly what I am looking for.


Rudolf Bargholz