【问题标题】:What's the equivalent bs-config.js (Browsersync) of this command?此命令的等效 bs-config.js (Browsersync) 是什么?
【发布时间】:2016-06-19 13:32:49
【问题描述】:

Browsersync 在 PHP/Symfony 3 项目中运行良好,使用以下命令:

browser-sync start --proxy http://localhost:8000 --files "web/css/**/*.css"

浏览器将在http://localhost:3000 打开,如果我在web/css 中更改某些内容,我可以在不重新加载整个页面的情况下看到更新的样式表。到目前为止一切顺利。

但它不适用于以下bs-config.js

module.exports = {
    "files": [
        "web/css/**/*.css"
    ],
    "server": false,
    "proxy": "http://localhost:8000"
};

还有命令:

browser-sync start

浏览器将无法加载,未检测到更改并且重新加载不起作用。我错过了什么?

【问题讨论】:

    标签: browser-sync


    【解决方案1】:

    试试这个:

    1º 创建“bs-config.js”: browser-sync init

    2º 打开文件并像这样编辑:

    module.exports = {
    "ui": {
        "port": 3001,
        "weinre": {
            "port": 8080
        }
    },
    "files": "web/css/**/*.css",
    "watchOptions": {},
    "server": false,
    "proxy": "http://localhost:8000",
    "port": 3000,
    "middleware": false,
    "serveStatic": [],
    "ghostMode": {
        "clicks": true,
        "scroll": true,
        "forms": {
            "submit": true,
            "inputs": true,
            "toggles": true
        }
    },
    "logLevel": "info",
    "logPrefix": "BS",
    "logConnections": false,
    "logFileChanges": true,
    "logSnippet": true,
    "rewriteRules": [],
    "open": "local",
    "browser": "default",
    "cors": false,
    "xip": false,
    "hostnameSuffix": false,
    "reloadOnRestart": false,
    "notify": true,
    "scrollProportionally": true,
    "scrollThrottle": 0,
    "scrollRestoreTechnique": "window.name",
    "scrollElements": [],
    "scrollElementMapping": [],
    "reloadDelay": 0,
    "reloadDebounce": 0,
    "reloadThrottle": 0,
    "plugins": [],
    "injectChanges": true,
    "startPath": null,
    "minify": true,
    "host": null,
    "localOnly": false,
    "codeSync": true,
    "timestamps": true,
    "clientEvents": [
        "scroll",
        "scroll:element",
        "input:text",
        "input:toggles",
        "form:submit",
        "form:reset",
        "click"
    ],
    "socket": {
        "socketIoOptions": {
            "log": false
        },
        "socketIoClientConfig": {
            "reconnectionAttempts": 50
        },
        "path": "/browser-sync/socket.io",
        "clientPath": "/browser-sync",
        "namespace": "/browser-sync",
        "clients": {
            "heartbeatTimeout": 5000
        }
    },
    "tagNames": {
        "less": "link",
        "scss": "link",
        "css": "link",
        "jpg": "img",
        "jpeg": "img",
        "png": "img",
        "svg": "img",
        "gif": "img",
        "js": "script"
    }};
    

    3º运行服务器: php -S localhost:8000

    4º 启动 BrowserSync: browser-sync start --config bs-config.js

    【讨论】:

      猜你喜欢
      • 2011-01-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-10-16
      • 2012-02-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多