Giter Club home page Giter Club logo

Comments (10)

evelynStraigt avatar evelynStraigt commented on July 25, 2024

πŸ‘

I would also love this feature, I did a really quick and dirty implementation on my own just to try something out and it's exactly what I need.

from live-server.

harrytruong avatar harrytruong commented on July 25, 2024

πŸ‘ I like the idea too, but could one of you guys submit a PR? Or document what exact behavior/flags you're referring to? I'm guessing it's something like:

$ live-server --watch=path,another/path

Where --listen is . by default, and can be a comma-separated string of paths.

from live-server.

dotnetCarpenter avatar dotnetCarpenter commented on July 25, 2024

@tapio @harrytruong --listen is undocumented in the README

from live-server.

arthurmchr avatar arthurmchr commented on July 25, 2024

+1

from live-server.

tapio avatar tapio commented on July 25, 2024

There is --ignore=path which could probably achieve the desired effect, if the less files are in a directory which can be ignored as a whole.

from live-server.

levithomason avatar levithomason commented on July 25, 2024

Pardon pseudo code, on my phone. Scanning the code (on my phone at least), looks like index.js at LiveServer.start() has this line

var watchPaths = [root];

Where root is the server root or cwd. I think adding a - - watch-paths OPTION that took a comma separated list and using in in the above line something like:

var watchPaths = options.watchPaths || [root]

Would do the trick. Then you can serve from the root, but only reload when a certain directory changes.

This is preferred over ignoring because in this use case you would need to ignore many files and directories to get the same result. Also, some files and directories can be generated during run time making it more ambiguous what to ignore.

I can do a PR for the full and proper enhancement if you'd like this option added.

from live-server.

levithomason avatar levithomason commented on July 25, 2024

Sorry about caps, phone typo!

from live-server.

tapio avatar tapio commented on July 25, 2024

Should probably think also about using watchr's ignoreCustomPatterns feature: might be nice to ignore e.g. all files that have .less/.scss extension.

from live-server.

levithomason avatar levithomason commented on July 25, 2024

Less files were just an example use case. The real fix here is targeting what to watch. For instance, it's common to have an app or src directory that has a build step that builds to a dist or build folder. There can be files of all types in both. The goal is, you only want to reload when the build / dist directory is updated, not based on file types.

There are similar patterns to this feature in Webpack's loader config. You can 'exclude' patterns from being run through the loader, but you can also 'include' patterns. The include is the recommended approach in the docs because it is explicit. There is a finite and well defined list of things you want to parse opposed to an infinite list of things you want to exclude (everything else).

Babel has a similar option with its register hook. You can compile 'only' certain patterns or 'ignore'. Or what if mocha had you ignore every directory that did not have tests in it?

I guess what I'm getting at is that when you know exactly what you want to watch, it is easier and makes more sense to explicitly define it that try to ignore every other possible thing.

That's my whole hearted attempt at a persuading you :) Whether the update makes it or not, still love the module and will probably keep using it.

from live-server.

levithomason avatar levithomason commented on July 25, 2024

Thanks, super appreciated @tapio!

from live-server.

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.