[英]how to prevent lite-server from opening browser window on startup?
I'm using the lite-server
with npm run lite
我正在使用带有npm run lite
的lite-server
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? 如何防止lite服务器在服务器启动时打开浏览器窗口?
thanks. 谢谢。
It seems like browserSync
has option open: false
似乎browserSync
有选项open: false
https://www.browsersync.io/docs/options/#option-open https://www.browsersync.io/docs/options/#option-open
try in your bs-config.js
试试你的bs-config.js
module.exports = {
"server": { "baseDir": "./src" },
"open": false
};
Or in bs-config.json
in your project's folder: 或者在项目文件夹中的bs-config.json
中:
{
"server": { "baseDir": "./src" },
"open": false
}
Lite-server uses Lite-server使用
BrowserSync
And allows for configuration overrides
via a local 并允许通过本地configuration overrides
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.
服务器的默认行为serves from the current folder
, opens a browser
,并将HTML5路由回退应用于./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:
例如,要更改项目的服务器端口,监视文件路径和基本目录,请在project's folder:
创建bs-config.json
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
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.