Browsersync Couldn't open browser Heroku

谁说胖子不能爱 提交于 2021-02-19 07:34:44

问题


Browsersync: when I use it locally it's all right. When I deploy on Heroku, I have this warning:

Couldn't open browser (if you are using BrowserSync in a headless environment, you might want to set the open option to false)

this is my package.json:

"scripts": {
"clean": "rimraf dist/{css/*,js/*,images/*}",
"autoprefixer": "postcss -u autoprefixer -r dist/css/*",
"scss": "node-sass --output-style compressed -o dist/css src/scss",
"lint": "eslint src/js || true",
"lint-scss": "stylelint src/scss/*.scss --syntax scss || true",
"uglify": "mkdirp dist/js -p && uglifyjs src/js/*.js -m -c -o dist/js/main.min.js",
"imagemin": "imagemin src/images/* -o dist/images",
"serve": "browser-sync start --server --files \"dist/css/*.css, dist/js/*.js, **/*.html, !node_modules/**/*.html\"",
"build:css": "run-s lint-scss scss autoprefixer",
"build:js": "run-s lint uglify",
"build:images": "run-s imagemin",
"build": "run-s build:*",
"watch:css": "onchange \"src/scss\" -- run-s build:css",
"watch:js": "onchange \"src/js\" -- run-s build:js",
"watch:images": "onchange \"src/images\" -- run-s build:images",
"watch": "run-p serve watch:*",
"postinstall": "run-s build watch"},
  "devDependencies": {
"autoprefixer": "^9.0.1",
"browser-sync": "^2.12.8",
"eslint": "^5.2.0",
"eslint-config-standard": "^12.0.0",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-node": "^7.0.1",
"eslint-plugin-promise": "^3.8.0",
"eslint-plugin-standard": "^3.1.0",
"imagemin-cli": "^3.0.0",
"mkdirp": "^0.5.1",
"node-sass": "^4.9.2",
"npm-run-all": "^4.1.3",
"onchange": "^4.1.0",
"postcss-cli": "^6.0.0",
"rimraf": "^2.5.4",
"stylelint": "^9.4.0",
"uglify-es": "^3.3.10"},
  "main": ".eslintrc.js"
}

I read that I have to set the open option to false, but I do not understand where and how.

Thanks


回答1:


Try replacing serve script with this:

"serve": "browser-sync start --no-open --server --files \"dist/css/*.css, dist/js/*.js, **/*.html, !node_modules/**/*.html\""


来源:https://stackoverflow.com/questions/52796013/browsersync-couldnt-open-browser-heroku

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!