Irina Rapoport
Irina Rapoport

Reputation: 1692

Change Meteor app's background on every build

Sometimes, after a change in the source code, I can't quite tell whether the built is complete and my app in browser is up to date now. Meteor's message "=> Client modified -- refreshing (x17) does not always allow to tell whether the message is new or stale; even if it did, my laptop has limited real estate, and just switching back and forth between text editor and browser becomes hassle enough, if done frequently.

What I'd like is an ability to change some visual attribute of the page every time the project is rebuilt or refreshed. How can I accomplish that?

Upvotes: 1

Views: 182

Answers (1)

saimeunt
saimeunt

Reputation: 22696

Here is a quick hack using an inlined style tag in the body to set the whole app background color to a random string of hexadecimal digits.

HTML

<body>
  <style>
    body{
      background-color: {{backgroundColor}};
    }
  </style>
</body>

JS

Template.body.helpers({
  backgroundColor: function(){
    return "#" + Random.hexString(6);
  }
});

You have to meteor add random to your project to access the Random utility.

https://docs.meteor.com/#/full/random

Upvotes: 2

Related Questions