While building large applications with meteor, we do face the regular problem of editing the stylesheets files. Once a file is edited, the whole application reloads which ta
Here is what you need (it looks fastidious but do not be afraid, it worth it):
Setup your project to externalise .css files
meteorProject/public
meteorProject/public/style.css
<link rel="stylesheet" type="text/css" href="/style.css" />
What you did ? You created a public repository accessible through the path localhost:3000/
then you added the stylesheet style.css to this repository, that one became available through the relative path /style.css
. By using this technique, meteor will not compile neither include by itself the stylesheet to your project, you just load it manually in the regular way using the link
tag. Now it is time to configure an editor.
Editing .scss files in realtime with meteor:
That takana is freaking awesome! the concept is the following: Once installed and ran it will create a server interacting with the sublimetext editor, then you are requested to add a js snippet to your code so that the browser will get connected with the takana server and reload the .css or .scss files in realtime without having to reboot meteor. To setup the meteor project with takana just do the following:
sudo npm install -g takana
(enter your password if requested)meteorProject/public
folder created above is might look something like: takana /Users/aUser/meteorProject/public
<script type="text/javascript" src="http://localhost:48626/takana.js"></script>
You are all set, now to use it
meteor
from the right path…http://localhost:3000
style.css
file, the css changes are automatically displayed on the browser page without saving anything.style.css
to style.css.scss
and edit it within sublime text. Here the magic happen, you are editing a scss file with live result on a meteor application without having to reload anything.Once you are satisfied with the result you can either compile the .scss to a .css file and add it the regular way to the project, or use the meteor .scss package which will do this for you at each restart. Note: Don't forget to remove the js and style snippet one to your code once in production.
Last but not least: you can open the project in several browsers and see them be refreshed in live while you edit the file in SublimeText, also it worked fine with Safari, FF but for some reasons I had to use "Google Chrome Canary" instead of "Chrome". Please comment if you made it work on other browsers such as IE, Opera or even if it worked with the regular "Chrome" on your computer.