I want my file/foder structure be clean on my website. So I don't want coffescript file be in the same folder as its compiled version.
While developing I'm using --watch key of compiler. I used this command before
coffee -cw ./ ./
which worked fine recursively for all coffeescript files when launching this from root of the website. But there is one problem - it puts compiled files in the same folder, which I try to avoid.
Is it possible to say to the compile - "please compile every coffeescript file and put compiled version in the parent folder"?
Update:
OK. A little bit of a clarification here. I.e. I have this folder structure
app
|- css
|- images
|- js
|- coffee
|- libs
|- controllers
|- coffee
|- services
|- coffee
|- loggers
|- coffee
As you can guessed I want to store all my coffeescript files inside coffee
folders, but compile them into the parent folder. E.g. I want to add one more logger, then I add newLogger.coffee
inside app/js/services/loggers/coffee and compiler compiles it and put newLogger.js
inside app/js/services/loggers.
I can use this command inside each coffee
folder
coffee -cw -o ../ ./
So, in this case with 4 coffee
folders I have 4 compiler instances running for each of them. Can I replace them with one instance?
You can do it with gruntjs task manager. With grunt you can specify any folder structure you want to maintain.
You can also add task to uglify all your js files after compilation.
Grunt is very useful for development, because it can watch your source files and recompile them after every change.
We're using it right now in our project to manage our front-end. Our task include:
.coffee
, .jade
and .less
files..js
and .css
files.Here's the example of gruntfile.coffee
which compiles, concatenates uglifies and deploys all .coffee
files from assets/js/
directory: https://gist.github.com/lbeschastny/5716323 (haven't tested it yet).
You can find more examples with the detailed instruction how to run them in getting started section of grunt site