How to disable cross-device action mirroring functionality of BrowserSync? (GhostMode)

让人想犯罪 __ 提交于 2019-11-30 05:50:53

Faced same problem, you can simply set ghost mode to false in init options.

     browserSync.instance = browserSync.init({
      startPath: '/',
      ghostMode: false,
      server: server,
      browser: browser
     });

no need to change in default.config.js :)

Sorry to answer my own question, but I found the answer a few days later and since no one has answered this yet I thought I'd post my solution.

The problem we were encountering seems to be caused by a feature in BrowserSync called "GhostMode" which mirrors click and scroll actions, as well as several form actions, across devices. Disabling this is very simple: Look for your BrowserSync config file (for me it was at root/node_modules/browser-sync/lib/default.config.js) and open that. Search in that file for something similar to the following:

ghostMode: {
    clicks: true,
    scroll: true,
    forms: {
        submit: true,
        inputs: true,
        toggles: true
    }
},

and change it so that it says ghostMode: false,

This fixed our issue and hopefully this will help others if they encounter the same problem.

In case you use the QuickStart seed to initialize your project, the settings of BrowserSync can be configured using bs-config.json file at project's root folder.

My file contains the following:

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