Prevent to merge all assets in meteor.js

What you want is called ‘code splitting’ and it is not currently possible using the standard Meteor setup. But it is a feature that is currently being worked on and should appear in the next few months or so (I guess). Once it does arrive it will be based around modules which is a feature that will land very soon in Meteor 1.3.

Note. Code splitting is not the solution to css conflicts, it’s simply more efficient.

Your options for code splitting are:

  1. Explore modules in 1.3, start adopting this pattern so that once code splitting arrives you are able to take advantage of it - I strongly suspect code splitting in Meteor will depend on you splitting you code into modules.
  2. If you can’t wait have a look at this thread which gives a custom approach to enabling code-splitting.
  3. Just relax. Build something that does what you need now based on the guide and trust in the guide’s authors to make the right decisions for you to ensure upgrading to code-splitting later will be easy.

Regarding your css conflicts:

You need to scope things. Just wrap mobileLayout in a css class, like mobile-layout, and then wrap all your css in the same class:

.mobile-layout {
  .myapp.widget {
    background: rgb(239, 239, 239);
    // etc. etc.
  }
  .some-other-thing {
    // etc.
  }
}

This won’t stop all css being sent to all clients but it will prevent conflicts.

1 Like