Book Image

Meteor Cookbook

By : Isaac Strack
Book Image

Meteor Cookbook

By: Isaac Strack

Overview of this book

Table of Contents (19 chapters)
Meteor Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Using CoffeeScript


Many people prefer CoffeeScript to the standard JavaScript syntax. If you are one of those people with a preference, Meteor has you covered. This recipe will show you how to quickly enable CoffeeScript in your development environment.

Getting ready

Nothing is needed to prepare for this recipe, other than having Meteor installed, and a project created so that you can begin using CoffeeScript.

How to do it…

To use CoffeeScript, proceed with the following steps:

  1. Open a terminal window and navigate to the root folder of your project.

  2. Enter the following command:

    $ meteor add coffeescript
    

    You should see the following response in the terminal window:

    coffeescript  added, version 1.0.
    

    CoffeeScript is now installed and ready to go!

You can test the installation by creating a .coffee file and adding a script (for example, add test.coffee to your client folder). When you start your Meteor application with the meteor command, the script should execute as designed.

Tip

You can uninstall CoffeeScript easily. Simply execute the following terminal command:

$ meteor remove coffeescript

How it works…

Behind the scenes, the CoffeeScript package you just installed looks for any and all *.coffee and *.litcoffee files, compiles them into native JavaScript, and then bundles them for use in your running Meteor application.

Note

As with all other files in a running Meteor application, changes to your CoffeeScript are immediately processed.

See also

  • The Adding Meteor packages recipe in Chapter 2, Customizing with Packages