官术网_书友最值得收藏!

Configuring Visual Studio

In this recipe, we will demonstrate how to add CoffeeScript support to Visual Studio.

Getting ready

If you are on the Windows platform, you can use Microsoft's Visual Studio software. You can download Microsoft's free Express edition (Express 2013 for Web) from http://www.microsoft.com/express.

How to do it...

If you are a Visual Studio user, Version 2010 and above can work quite effectively with CoffeeScript through the use of Visual Studio extensions.

If you are doing any form of web development with Visual Studio, the Web Essentials extension is a must-have.

To install Web Essentials, perform the following steps:

  1. Launch Visual Studio.
  2. Click on the Tools menu and select the Extensions and Updates menu option. This will display the Extensions and Updates window (shown in the next screenshot).
  3. Select Online in the tree on the left-hand side to display the most popular downloads.
  4. Select Web Essentials 2012 from the list of available packages and then click on the Download button. This will download the package and install it automatically.
  5. Once the installation is finished, restart Visual Studio by clicking on the Restart Now button.

    Tip

    You will likely find Web Essentials 2012 ranked highly in the list of Most Popular packages. If you do not see it, you can search for Web Essentials using the Search box in the top-right corner of the window.

    How to do it...

Once installed, the Web Essentials package provides many web development productivity features, including CSS helpers, tools to work with Less CSS, enhancements to work with JavaScript, and, of course, a set of CoffeeScript helpers.

To add a new CoffeeScript file to your project, you can navigate to File | New Item or press Ctrl + Shift + A. This will display the Add New Item dialog, as seen in the following screenshot. Under the Web templates, you will see a new CoffeeScript File option. Select this option and give it a filename, as shown here:

How to do it...

When we have our CoffeeScript file open, Web Essentials will display the file in a split-screen editor. We can edit our code in the left-hand pane, while Web Essentials displays a live preview of the JavaScript code that will be generated for us.

The Web Essentials CoffeeScript compiler will create two JavaScript files each time we save our CoffeeScript file: a basic JavaScript file and a minified version. For example, if we save a CoffeeScript file named employee.coffee, the compiler will create employee.js and employee.min.js files.

Tip

Though I have only described two editors to work with CoffeeScript files, there are CoffeeScript packages and plugins for most popular text editors, including Emacs, Vim, TextMate, and WebMatrix.

主站蜘蛛池模板: 江达县| 绍兴县| 苏尼特右旗| 栖霞市| 松江区| 新和县| 肥东县| 北安市| 昆山市| 耒阳市| 满城县| 文安县| 新宁县| 新晃| 香格里拉县| 高碑店市| 铁岭县| 金沙县| 肥东县| 太白县| 顺义区| 岑溪市| 松阳县| 阳高县| 灌南县| 修水县| 独山县| 仪征市| 玉山县| 竹山县| 芜湖县| 云阳县| 嘉峪关市| 抚顺县| 弋阳县| 大丰市| 沈丘县| 若尔盖县| 任丘市| 依安县| 凤山市|