Skip to content

Compile Coffescript files one by one #193

@chopachom

Description

@chopachom

Hi guys!
I'm using ver 0.7.1 and trying to compile coffeescript files into js files and I have the following bundle configuration:

coffee_bundle = Bundle('coffee/*.coffee',
    filters='coffeescript'
)

jslibs_bundle = Bundle("js/lib/*.js")

jsall_bundle = Bundle(coffee_bundle,jslibs_bundle, 
    filters="coffeescript,jsmin", output="js/app.js"
)

in my template:

{% assets "jsall_bundle" %}
    <script type="text/javascript" src="{{ ASSET_URL }}"></script>
{% endassets %}

In debug mode this produces

<script type="text/javascript" src="/static/coffee/test.coffee"></script><!-- DO NOT WANT .coffee (actually expected test.js)-->
<script type="text/javascript" src="/static/js/lib/bootstrap.js"></script>    
<script type="text/javascript" src="/static/js/lib/handlebars-1.0.rc.1.js"></script>    
<script type="text/javascript" src="/static/js/lib/jquery-1.8.2.js"></script>

As you can see coffescript files aren't compiled, so, I thought maybe I should specify debug=False to the coffee_bundle, but this results in the following error:

BuildError: No output target found for <Bundle output=None, filters=[<webassets.filter.coffeescript.CoffeeScriptFilter object at 0x1019414d0>], contents=('coffee/*.coffee',)>

Ok, lets add output :

coffee_bundle = Bundle('coffee/*.coffee',debug=False,
    filters='coffeescript', output="js/coffee.js"
)

Ok, coffescript files are compiling now, but they are merged into one file, which is not a desirable result because it's hard to debug

<script type="text/javascript" src="/static/js/coffee.js?4913d094"></script>    
<script type="text/javascript" src="/static/js/lib/bootstrap.js"></script>    
<script type="text/javascript" src="/static/js/lib/handlebars-1.0.rc.1.js"></script>    
<script type="text/javascript" src="/static/js/lib/jquery-1.8.2.js"></script>

So the question is how can I compile .coffee files one by one in debug mode and merge them with other js files in production mode? Is it possible?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions