Was searching this same topic today, but for NOT loading things in production vs development. Found the following type of approach, here is an example of what I think you are shooting for
When I run process.env.NODE_ENV in the console on my local machine I get development and when I run it on a deployed Galaxy instance I get production
I’m guessing this is the variable that is set by Meteor, but I’ve not really investigated where/when it gets set.
I assume you set isProduction as a variable just not show in your code snippet:
var isProduction = Meteor.isProduction;
if (isProduction) {
require('./ssr-init')
}
When I run Meteor.isProduction on my local machine and then on my Galaxy deployed app, I get false and true as I would expect. I’m not sure why that wouldn’t work for you.
I should have been more clear initially, but yeah I do have isProduction set above. The issue is that this still breaks client only refresh. It works limiting ssr to dev, but Meteor still registers UI changes as server changes.
We found the same limitation for our projects. We ended creating pre-deploy and post-deploy scripts that comment and un comment those lines, so that we get faster dev speed’s by not including some shared files on the server.