I have a directory structure like this:
+ src
|
| - modules
| |
| | - auth
| | |
| | | - auth.coffee
| | | - auth.sass
| | | - login.html
| | | - logout.html
| |
| | - navigation
| | |
| | | - navigation.coffee
| | | - navigation.sass
| | | - navbar.html
| |
| - scripts
| |
| | - vendor
| | |
| | | - underscore.js
| | | - angular.js
| |
| | - app.coffee
| | - router.coffee
|
| - styles
| |
| | - config.sass
| | - style.sass
I want to:
Watch all .coffee
, .sass
and .html
files and do steps 2 and 3 when a file has changed
Compile the .coffee
and .sass
files.
For both i need to specify dependencies (or: a specific ordering).
scripts/vendor/underscore.js
scripts/vendor/angular.js
scripts/*.js
modules/**/*.js
styles/config.sass
styles/style.sass
modules/**/*.sass
Collect all .js
, .css
and .html
files and organize them for the public folder.
This is the desired output
+ public
|
| - partials
| |
| | - auth
| | |
| | | - login.html
| | | - logout.html
| |
| | - navigation
| | |
| | | - navbar.html
| |
| - scripts
| |
| | - app.js
|
| - styles
| |
| | - app.css
I tried many tools, but couldn't get the desired result. For example Flour for the Coffeescript had problems with wildcards in compile methods.
I think the best thing would be a Cakefile that does everything for me. How can i accomplish this?
First, why compile underscore or angular? Just link to the minified version on a CDN. You might be able to get better performance by packing those together with your app js, I don't have a solid yes/no answer on this, you'll have to research.
I think you should be able to accomplish this with grunt. My config isn't exactly what you want but:
# Project configuration.
grunt.initConfig
watch:
coffee:
files: ['app/assets/src/coffee/**/*.coffee', 'app/assets/src/coffee/*.coffee', 'test/*.coffee', '!**/screencaps/**', 'app/webserver.coffee']
tasks: ['coffee:dev', 'replace', 'mochaTest']
grunt.loadNpmTasks("grunt-contrib-coffee")
grunt.loadNpmTasks('grunt-contrib-watch')
Etc. Grunt uses glob for file pattern matching. For what you want to do I'd set up a chain of watch commands:
src/modules/*.coffee
public/scripts
.