Meteor Capture

Project structure

When you run meteor create you get the most basic project structure you can imagine, and one reason why we can do this is that any code written inside if (Meteor.isClient) will only run on the client, not surprisingly anything inside if (Meteor.isServer) will only run on the server, and anything else will run on both!

Meteor looks for a few specially named directories: server, client, private, client/compatibility, lib and public. Files that live in the client directory are treated as such, and the same applies to server.

public is for serving static assets, like images.

lib is another special directory and we can create it anywhere (outside of private, lib, and public), files placed here are loaded first.

Files within client/compatibilty are executed without being wrapped in a new variable scope.

Here's a simple, solid project structure to get started with:

  • client
    • lib
    • stylesheets
    • views
      • application
        • 404.html
        • layout.html
      • components
      • example
        • show.js
        • show.html
        • show.import.less
        • ...list, item, edit
    • main.js
    • main.html
    • main.less
  • lib
    • collections
      • books.js
      • authors.js
    • router.js
  • packages
  • public
  • server
    • publications.js

For further information on structuring your application, and details on how Meteor loads your files refer to:

http://docs.meteor.com/#structuringyourapp

See Also

https://www.eventedmind.com/feed/meteor-introducing-the-em-scaffolding-tool

Chris Mather has created a scaffolding tool that automatically creates project structure, files and boilerplate code.

http://github.differential.io/meteor-boilerplate/

Differential have created meteor-boilerplate, which comes with a bunch of good packages out of the box, including iron-router, bootstrap 3, font-awesome, collection-helpers, factory and less.

comments powered by Disqus