Flask-Cake runs CoffeeScript Cake files automatically on filesystem changes. This is useful, for example, when you want to perform tasks like compile all CoffeeScript files in to JavaScript files.


The Flask-Cake extension can be easily installed. To install with easy_install:

$ easy_install Flask-Cake

Alternatively, if you have pip installed:

$ pip install Flask-Cake


You initialize the extension by creating an instance of flask_cake.Cake:

from flask import Flask
from flask_cake import Cake

app = Flask(__name__)
cake = Cake(app)

Like most Flask extensions, a Flask-Cake instance may be used with multiple applications by initializing with flask_cake.Cake.init_app():

app = Flask(__name__)
cake = Cake()

Currently, Flask-Cake requires you to have a directoy structure like this:


Inside the Cakefile, you need to have a build task. This will be configurable in the future, along with the path to the Cakefile. The build task can do whatever you want. Here is a simple example that combines many different .coffee files into a single .js file in a different directory:

{exec} = require 'child_process'

coffeeFiles = [

task 'build', 'Build PunchedOut! JavaScript file', ->
    console.log 'Building PunchedOut! application.js file...'

    exec "coffee --join app.js --output ../js/ --compile #{coffeeFiles.toString().replace(/,/g, ' ')}"

CoffeeScript documentation

The following links might be useful for furthur information:

Fork me on GitHub