how to prevent lite-server from opening browser window on startup?
Asked Answered
K

2

16

I'm using the lite-server with npm run lite

my config file,

module.exports = {
    "server": { "baseDir": "./src" }
};

whenever I start the server, it opens up a new browser window. How do I prevent lite server opening browser window on server startup?

thanks.

Katzman answered 11/3, 2016 at 1:8 Comment(1)
lite-servers uses browserSync, it might help youMisguidance
P
22

It seems like browserSync has option open: false

https://www.browsersync.io/docs/options/#option-open

try in your bs-config.js

module.exports = {
    "server": { "baseDir": "./src" },
    "open": false
};

Or in bs-config.json in your project's folder:

{
   "server": { "baseDir": "./src" },
   "open": false
}
Patristic answered 19/3, 2016 at 13:6 Comment(0)
H
4

Lite-server uses

BrowserSync

And allows for configuration overrides via a local

bs-config.json

or

 bs-config.js

file in your project.

The default behavior of the server serves from the current folder, opens a browser, and applies an HTML5 route fallback to ./index.html. so we need to set the configuration

For example, to change the server port, watched file paths, and base directory for your project, create a bs-config.json in your project's folder:

{
  "port": 8000,
  "files": ["./src/**/*.{html,htm,css,js}"],
  "server": { "baseDir": "./src" }
}

So for browser not opening you have to set like this

{
  "port": 8000,
  "files": ["./src/**/*.{html,htm,css,js}"],
  "server": { "baseDir": "./src" },
  "open":false
}
Hale answered 26/3, 2016 at 12:20 Comment(4)
Any idea how to do this when lite-server is used with concurrently (as in angular 2's "starter kit")?Japeth
@Japeth I think it depends on the files and folder structure you should come up with baseDir option as stated above change it according to your app structure and modify the filesHale
the thing is lite server is run without any specific option with concurrently package. I'm not sure how it works. my goal would be knowing where to put lite server's config fileJapeth
@Japeth at the root of application you keep the configurations fileHale

© 2022 - 2024 — McMap. All rights reserved.