Instaneous compilation of less, coffee, running tests

135 views
Skip to first unread message

Petr Blahos

unread,
Nov 4, 2012, 2:29:16 PM11/4/12
to pylons-discuss
Hi all,

I have seen a very nice thing in the js framework este (https://github.com/Steida/este). 
What he does there, he basically has a file watcher and whenever his style changes,
it is compiled with stylus, whenever his coffee script changes, it gets translated to 
js, whenever his js changes, tests are run.

I have started implementing this by copying pserve.py into my project and enhancing
its file monitor with a possibility to have a callback, which is called every second.
In this callback I (conditionally) compile my styles, and run unit tests. It's working 
nicely, but I have doubts whether this is the best way to go about it - meaning 
extending pserve. I somehow feel, that maybe this is not the right task for pserve,
and I should do it the other way round - implement my own file monitor, which will 
control the restarting of my pyramid app, and compiling files and running tests. I will
be greatful for any opinions.

(I know about fanstatic and pyramid_fanstatic. Good for resource inclusion, but not
what I seek for the less/stylus-->css.)

Cheers,
Petr

Malthe Borch

unread,
Nov 4, 2012, 3:16:10 PM11/4/12
to pylons-...@googlegroups.com
On 4 November 2012 20:29, Petr Blahos <petrb...@gmail.com> wrote:
> What he does there, he basically has a file watcher and whenever his style
> changes,
> it is compiled with stylus, whenever his coffee script changes, it gets
> translated to
> js, whenever his js changes, tests are run.

You can do this sort of thing in bash if you wanted:
https://gist.github.com/2864947.

\malthe

Randall Leeds

unread,
Nov 4, 2012, 4:45:18 PM11/4/12
to pylons-...@googlegroups.com
You could have a look at miracle2k/webassets or tav/assetgen.
Both have pyramid integration projects and both handle content-hash-based automatic recompilation.



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

Petr Blahos

unread,
Nov 5, 2012, 2:04:35 PM11/5/12
to pylons-discuss
I was thinking about using good old makefile, together with an approach like
you mentioned. Simply: something changed? make. It has to run on Windows 
though (I have no choice). I know there is make on windows too, but it complicates
matters enormously.
--
Petr


Petr Blahos

unread,
Nov 5, 2012, 2:08:57 PM11/5/12
to pylons-discuss
You could have a look at miracle2k/webassets or tav/assetgen.
Both have pyramid integration projects and both handle content-hash-based automatic recompilation.

webassets look good. Somehow it feels better than fanstatic. Now I am starting to 
thing in a different direction, which is: If I am in a debug mode, I will start a thread
directly in my pyramid app (probably in a modified pyramid_webassets), which will
take care of the periodic compilation of the resources. Meaning, not when they are 
required, but when sources change (based on a set of bundles defined in webassets).

Thanks for your pointers.
--
Petr



Michael Merickel

unread,
Nov 5, 2012, 2:17:15 PM11/5/12
to Pylons
I believe pyramid_webassets + webassets already handles compiling sources for you based on the filters you define within each bundle.


Randall Leeds

unread,
Nov 5, 2012, 3:06:50 PM11/5/12
to pylons-...@googlegroups.com
On Mon, Nov 5, 2012 at 11:17 AM, Michael Merickel <mmer...@gmail.com> wrote:
I believe pyramid_webassets + webassets already handles compiling sources for you based on the filters you define within each bundle.

It's true. I'm using webassets today in this way. When configured in debug mode, it should compile assets as needed, when sources change, on every page load. Combined with `pserve --reload`, to restart the paste server when python files change, it makes for a very low-friction development workflow.
 

Andi Balke

unread,
Nov 5, 2012, 3:18:45 PM11/5/12
to pylons-...@googlegroups.com
hi, 

just wanted to mention my two cents :)

we use fanstatic and less in our pyramid application. both things are great (though i don't know about webassets yet). 

first we had the ``lessc`` in pyramid as explained here: http://www.gawel.org/weblog/en/2011/12/Using_lesscss_with_pyramid_and_fanstatic
this has several disadvantages: 
- compilation of a ``less`` file to ``css`` causes the app to restart, as lessc is run on start (too slow)
- lessc must be in the path when starting the app; useless restriction on a production machine and a little hazzle in a buildout environment with self-built nodejs
- no option to add another build-step like compressing the ``css`` files 

we dropped the solution above and i just built a simple nodejs script that watches our files and compiles on demand (really short latency, no app restart). this watcher is automatically started in the local ``supervisord``, which is configured by buildout. on production there is no lessc or anything nodejs-related. 

fanstatic itself - just to mention that - is great for us because of the excellent resource handling and the ability to package and version static files on production. 

hope this helps, andi


Reply all
Reply to author
Forward
0 new messages