15

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.

2 Answers2

21

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
}
Dmitriy Nevzorov
  • 6,042
  • 1
  • 20
  • 28
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
}
Ankanna
  • 737
  • 2
  • 8
  • 21
  • Any idea how to do this when lite-server is used with concurrently (as in angular 2's "starter kit")? – dragonmnl Jun 21 '16 at 18:53
  • @dragonmnl 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 `files` – Ankanna Jun 22 '16 at 11:53
  • 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 file – dragonmnl Jun 22 '16 at 12:44
  • @dragonmnl at the root of application you keep the configurations file – Ankanna Jun 22 '16 at 14:15