miracle2k / flask-assets

Flask webassets integration.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Compiling files from non-default folder

italomaia opened this issue · comments

I have a project with the following structure:

project
-blueprints
--myblueprint
---coffee
---static

I wish to compile coffeescript files from myblueprint/coffee into myblueprint/static. Is flask-assets capable of such? If not, I would like to leave it as a feature request. Thanks.

Yes, that should be possible.

The complication is this:

  • The base webassets library has a system of load paths - any paths you like can be used as a source, and all output files are written to 'env.directory'. This allows you to do what you want.
  • flask-assets replaces that system with one based on Flask's blueprints and static folders. This doesn't allow you to do what you want.

In principle you have to choose one of them. If you want the first, you have to forgo the second. That is, you have to set up all paths and urls so that they match the Flask static routing.

In addition, it is now possible to change the configuration for just one bundle. It might be possible to do this:

  coffee = Bundle('foobar.coffee', filters='coffee') 
  coffee.config.directory = 'path/to/coffee/dir
  coffee.config.url = ''  # probably not required, you never want to serve the coffee files directly.

  # Ideally, the rest of the system still uses the Flask-Assets url integration.
  main = Bundle(coffee, other_bundles)