Comments (6)
I think you can handle that with 2 rules:
guard 'livereload', {apply_css_live: true} do
extensions = [:css, :js, :html, :png, :gif, :jpg, :jpeg]
watch(%r{templates/.+\.(#{extensions * '|'})})
end
guard 'livereload', {apply_css_live: false} do
extensions = [:js, :html, :png, :gif, :jpg, :jpeg]
watch(%r{templates/.+\.(#{extensions * '|'})})
end
Does this help?
from guard-livereload.
Thanks @e2, I tried that but it didn't work as expected. I then noticed that the regex was too permissive and was detecting a change to files like main.css.map. I put an end-of-string constraint into the regex and it works like a charm now with just the one rule:
guard 'livereload', apply_css_live: true do
extensions = [:css, :js, :html, :png, :gif, :jpg, :jpeg]
watch(%r{templates/.+\.(#{extensions * '|'})\z})
end
Feel free to close this if unless there's something you'd like to add :)
from guard-livereload.
Thanks! I added a test, fixed the template and merged to master.
from guard-livereload.
You're welcome :) Glad to be of some help. I assume the \z
is the better approach vs $
? Is it only ever receiving one path at a time?
from guard-livereload.
Yes, the watch is matched against all files individually (out of the batch of changed files).
The "\z" and "$" make no difference, unless people have newlines in their file names (unlikely).
If you have any suggestions, feel free to open issues with ideas. I'm sometimes too deep into these projects, so it's easy for me to miss the obvious.
Tweaks like these seem small, but they actually save people a lot of time and frustration - and that's a big thing.
from guard-livereload.
Thanks @e2, that makes sense to me. My template developer is much happier with the performance of not having to refresh the whole page now :)
Thanks also for your feedback. It's great to hear these things make a difference for others :)
from guard-livereload.
Related Issues (20)
- Security Vulnerability - possible to read arbitrary files via socket HOT 2
- Not reloading CSS correctly with config.assets.debug = false HOT 8
- Error installing guard-livereload
- Where is the package located? HOT 5
- not compatible with ruby-2.3.3 and Rails 5.0.0.1 HOT 1
- Not working with Ruby 2.4.0 and Rails 5.0.1 HOT 2
- guard livereload using ipv4 only . how to force to use ipv6. HOT 1
- Hangs when retrieving livereload.js
- Cannot init or load guard-livereload on Ruby 2.4.1/Windows HOT 4
- Could not find eventmachine-1.2.5 in any of the sources HOT 1
- "no acceptor" rspec error HOT 3
- Error "Could not parse data entirely (0 != 609) (HTTP::Parser::Error)" HOT 4
- Wiki page dead links: Usage::2. Adding a snippet to your web page HOT 2
- undefined method `epoll?' for EventMachine
- there is no add-ons' URL link of FireFox. HOT 1
- No such file or directory -- /usr/lib/ruby/vendor_ruby/guard/_guard-core
- guard-livereload reports with undefined method epoll? error HOT 5
- CSS edits lose styling after reload HOT 3
- Rails 7.0.0 HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from guard-livereload.