#!/usr/bin/env python3
from os.path import dirname
from livereload import Server
from other_module import gen_css_bundle
SERVER = Server()
SERVER.watch('index.html')
SERVER.watch('assets/css/main.css', gen_css_bundle)
SERVER.serve(root='.')
The gen_css_bundle function takes a few milliseconds to execute and edit index.html to insert the new bundle filename.
When I run this script and edit main.css, I see the following logs:
I want to introduce a mechanism in livereload in order to control this "ignore" logic,
so that in my case the brower is reloaded once index.html has been edited by gen_css_bundle.
Suggested solution
Hence, this PR introduces a livereload.handlers.LiveReloadHandler.DEFAULT_RELOAD_TIME class constant,
that can be used this way:
#!/usr/bin/env python3
from os.path import dirname
from livereload import Server
from livereload.handlers import LiveReloadHandler
LiveReloadHandler.DEFAULT_RELOAD_TIME = 0 # do not ignore index.html edition by gen_css_bundle and trigger browser reload
from other_module import gen_css_bundle
SERVER = Server()
SERVER.watch('index.html')
SERVER.watch('assets/css/main.css', gen_css_bundle)
SERVER.serve(root='.')
Use case
I use the following
watch_and_serve.py
script:The
gen_css_bundle
function takes a few milliseconds to execute and edit index.html to insert the new bundle filename.When I run this script and edit
main.css
, I see the following logs:I want to introduce a mechanism in
livereload
in order to control this "ignore" logic, so that in my case the brower is reloaded onceindex.html
has been edited bygen_css_bundle
.Suggested solution
Hence, this PR introduces a
livereload.handlers.LiveReloadHandler.DEFAULT_RELOAD_TIME
class constant, that can be used this way: