coffeescript - django-require and require-cs -
has used django-require , require-cs together?
i stuck when deploying application. want coffee files compiled js , coffee-script.js excluded build.
i added own build profile (using require_build_profile) , used this build file example, doesn't seem work.
yeah, if post build.js , settings.py, that'd great ;)
to use coffeescript requirejs, need load coffeescript files using cs! loader plugin.
for example, given file structure this:
- js
- main.js // main script file, minimal javascript stub.
- cs.js // coffeescript loader plugin.
- coffee-script.js // coffeescript compiler.
- csmain.coffee // actual coffeescript main file.
- module1.coffee // coffeescript module.
- module2.coffee // coffeescript module.
- app.build.js // app build profile.
then, in main.js file, can bootstrap coffeescript app this:
require(["cs!csmain"])
your csmain.coffee file can run app, this:
require([ "cs!module1", "cs!module2" ], (module1, module2) -> module1.dosomething module2.dosomething
a build profile should take care of optimization:
({ stubmodules: ['cs'], modules: [ { name: 'main', exclude: ['coffee-script'] } ] })
Comments
Post a Comment