Coder Social home page Coder Social logo

Comments (6)

e2 avatar e2 commented on August 15, 2024

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.

brendon avatar brendon commented on August 15, 2024

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.

e2 avatar e2 commented on August 15, 2024

Thanks! I added a test, fixed the template and merged to master.

from guard-livereload.

brendon avatar brendon commented on August 15, 2024

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.

e2 avatar e2 commented on August 15, 2024

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.

brendon avatar brendon commented on August 15, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.