sarsamurmu / reboost

A super fast dev server for rapid web development
MIT License
61 stars 3 forks source link

Serving/opening more than one html files at the same time #54

Closed GHNewbiee closed 3 years ago

GHNewbiee commented 3 years ago

I practically face the following problem: Very often, I need to change to a different html page among a number of them.

The first solution is to start separately the server for each page, but it is not so elegant and sophisticated at all!

The second and obvious solution is, every time, to (un)comment the relevant pages in contentServer.index and restart the server. It's very boring!

The third solution is to put all pages as links inside a main page with the rest of the files and call them from there. It's Ok but not the ideal!

The fourth solution is contentServer.index can also accept an array of pages. In this case, for each html page server creates a list of watched files. When a watched file changes, server finds the corresponding page and reload it. If the file is common to more than one html pages than all relevant pages are reloaded. Does it make sense?

In addition, server would automatically open only the first page or all of them found in the array, one by one in different tabs or windows.

What do you think?

Tia

sarsamurmu commented 3 years ago

You can do it in v0.20.1. Do it like this

reboost.js

const { start } = require('reboost');

// Base options for every content server
const baseOpt = {}

start({
  contentServer: [
    {
      ...baseOpt,
      name: 'server-one',
      root: './dir1',
      index: 'index.html'
    },
    {
      ...baseOpt,
      name: 'server-two',
      root: './dir2',
      index: 'index2.html'
    }
  ],
  // ...other configurations
})

Hope it helps you.