Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using coffeescript with basic Yeoman project.

I've used Yeoman to make a quick project skeleton using the yo webapp generator command. In the resulting Gruntfile I see that it's setup to compile CoffeeScript but it seems like its just sticking compiled files in a tmp folder.

coffee: {
    dist: {
        files: {
           '.tmp/scripts/coffee.js': '<%= yeoman.app %>/scripts/*.coffee'
        }
    },
},

How do these get included in the project during development. I'm not using RequireJS.

The yeoman docs are unclear on how to use coffeescript. They only mention that it gets automatically compiled.

like image 534
Christian Schlensker Avatar asked Feb 18 '13 18:02

Christian Schlensker


2 Answers

Using yeomen 1.0.0-rc1.4. I use:

$ yo angular --coffee

The resulting project has controller and app scripts in CoffeeScript.

grunt configuration file remains in js (what is not really a problem).

Running

$ grunt test

runs tests and all seems fine.

$ grunt server

is also doing what one expects (build the app, test it, starts server, opens the app in web browser and starts watching for changes, so if I change a coffee script file, it is quickly reflected in the web broser.

Documentation also states, one can use yo to add particular pieces like

  • angular:controller
  • angular:directive
  • angular:filter
  • angular:route
  • angular:service
  • angular:decorator
  • angular:view

each can be called with a --coffee switch and get the script in CoffeeScript, e.g.:

yo angular:controller user --coffee
like image 128
Jan Vlcinsky Avatar answered Sep 23 '22 03:09

Jan Vlcinsky


I just found an issue in the github repo referencing this problem. https://github.com/yeoman/generator-webapp/issues/12

It offers a temporary solution: https://github.com/yeoman/generator-webapp/issues/12#issuecomment-13731929

like image 32
Christian Schlensker Avatar answered Sep 21 '22 03:09

Christian Schlensker