On Mon, 2012-01-16 at 05:28 -0800, Martin Stein wrote:
> Hi everyone,
> 
> For the current project at work, we are looking into using require.js
> (http://requirejs.org/) to combine, modularize and minify our
> javascript. So, basically, we need to have a server-side build step
> before serving our static files. Our plan is as follows:
> 
> - have our pre-build javascript files in the usual '/static' directory
> - put the results from require's optimizer to a '/static-build'
> directory. (The require.js docs recommend a separate directory.)
> 
> Depending on development or production scenario (taken from .ini-
> file), the static files should be served from one or the other
> directory. However, so far I don't see a nice approach to this. When
> we started the project, we used the normal Pyramid approach in our
> templates. In our __init__.py, we have something like:
> 
> config.add_static_view('static', 'myproject:static',
> cache_max_age=3600)
> 
> In the jinja-template, we created the links with
> 
> <script src="{{request.static_url('myproject:static/js/
> application.js')}}" type="text/javascript"></script>
> 
> But if the directory changes from 'static' to 'static-build', we would
> have to change all our static_url(..) calls. Is there a way to make
> the resource 'myproject:static' refer to a different directory,
> depending on .ini configuration?

config.override_asset(to_override='myproject:static/',
                      override_with='myproject:static-build/')

.. should do it. 

See
http://docs.pylonsproject.org/projects/pyramid/en/1.3-branch/narr/assets.html#overriding-assets

 You can put the values for "to_override" and "override_with" in
the .ini file as necessary:

http://docs.pylonsproject.org/projects/pyramid/en/1.3-branch/narr/startup.html#deployment-settings

- C


- C


-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en.

Reply via email to