Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 895
Rivadiz Avatar asked Mar 11 '16 01:03

Rivadiz


People also ask

How do I turn off Lite-server?

Use the key combination CTRL + C .

What is the use of Lite-server?

Lite-server is a lightweight development server that serves a web application, opens it in the browser, and refreshes the page when HTML or JavaScript changes are made to the source code.

What is BS config JSON?

bsconfig. json is the single, mandatory build meta file needed for rescript . The complete configuration schema is here. We'll non-exhaustively highlight the important parts in prose below.


2 Answers

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
}
like image 140
Dmitriy Nevzorov Avatar answered Oct 05 '22 22:10

Dmitriy Nevzorov


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
}
like image 29
Ankanna Avatar answered Oct 05 '22 23:10

Ankanna