I am working on an implementation of a web service where we are writing our front end code in CoffeeScript. The problem I have stumbled on is while the project is growing functionality has to be separated in different files. What I really need is a simple structure where in the utils.coffee
file I will have the general functions which are required from every page and on each separate file I will have page_foo.coffee
page_bar.coffee
the specific functions. How can I structure it properly so I also make sure utils.coffee
loads first and is accessible from everyone?
With CoffeeToaster you have the ability to include files that you'll need at the top of them, making sure your final ".js" file (that will be also a merge of all your CoffeeScript files) have everything in the proper order, for use inside the browser.
Take a look on the docs:
http://github.com/serpentem/coffee-toaster
It comes also with a packaging system that when enabled will use your folder's hierarchy as namespaces declarations to your classes if you want so, then you can extends classes from multiple files, do imports and son, such as like:
#<< another/package/myclass
class SomeClass extends another.package.MyClass
The build configuration is extremely minimalist:
# => SRC FOLDER
toast 'src_folder'
# => VENDORS (optional)
# vendors: ['vendors/x.js', 'vendors/y.js', ... ]
# => OPTIONS (optional, default values listed)
# bare: false
# packaging: true
# expose: ''
# minify: false
# => HTTPFOLDER (optional), RELEASE / DEBUG (required)
httpfolder: 'js'
release: 'www/js/app.js'
debug: 'www/js/app-debug.js'
There's even a debug option that compile files individually for ease the debugging processes and another useful features.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With