faucet-pipeline / aiur

a simple styleguide generator

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Serve static files (with optional Live reloading)

FND opened this issue · comments

commented

Personally, I prefer manually refreshing the page to see (and compare) changes; live reloading just gets in my way. So it would be helpful if that was optional.

Ideally, I'd like to avoid installing the live-server dependency in the first place. In fact, lib/server.js seems to be entirely agnostic of the specifics of this project, so it could be launched independently. Perhaps the module could be included for convenience, but users would be prompted to install live-server themselves? 🤷‍♂️

    styleguide: [{
        source: "./pages.js",
        target: "./dist",
        server: require("…/lib/server")
    }]

I'm pretty sure that most users want live reload and that not wanting live reload is the option. So I think I would prefer to just have a liveReload option that you can set to false. I know that this means an unnecessary dependency for you, but it's a better "getting started" experience for the other users 😸

commented

A highly scientific poll elsewhere suggests your assumption is incorrect: There's a significant number of people (n > 0) who, like me, are irritated by live reloading. Obviously I'm biased, but that to me suggests opting into live reloading would accommodate a broader audience: Opt in turns live reloading into a pleasant enhancement for those who want it, opt out means it's an annoyance for those who don't. That's also why opt in strikes me as more intuitive and easier to document.

Having said that, you're the boss around here, so of course it's up to you.

Update: In discussion elsewhere, we've agreed that this is in fact a user-specific rather than a project-specific option, so a CLI flag would be the correct™ way to go about this. As for dependencies, well, that's still up in the air.

For people who don't want a live server, do they also don't want a server at all? Because if they want a server, we need to find a solution for that as our server always does live reloading and we would need to switch to another server for that.

commented

While I wouldn't want that, I'm guessing serving via HTTP (as opposed to file://) will be necessary in a lot of cases (mostly due JavaScript APIs' origin restrictions) and making people choose their own might be annoying for many. Luckily servedir does the job and only has a single dependency.

Ok, so I guess the solution here is... we remove the port configuration from the config file. If you provide no CLI option, you get no server. There are two options:

  • --serve $PORT serves the files via servedir
  • --livereload $PORT serves the files via live-server
    You can't combine the two options. To reduce the dependencies, we could not add them as dependencies. When you provide the configuration, we will attempt to load it and ask you to install it if it is not there (as implemented in faucet).
commented

I'd be happy (FCVO) with that. --livereload looks pretty cumbersome, but luckily I won't ever have to type that.

This will be implemented by using faucet-pipeline/faucet-pipeline-core#59

Already done (for a while)