【问题标题】:Browsersync doesn't set the right local urlBrowsersync 没有设置正确的本地 url
【发布时间】:2015-02-13 13:26:34
【问题描述】:

我正在使用与 MAMP PRO 相关联的入门主题 Roots with Gulp 进行 Wordpress 项目。我遇到了来自 gulpfile.js 的“监视”任务的问题。 下面是任务的代码:

gulp.task('watch', function() {
  browserSync({
    proxy: "mywebsite:8888",
    port: 8888,
    open: "internal"
  });
  gulp.watch([path.source + 'styles/**/*'], ['styles']);
  gulp.watch([path.source + 'scripts/**/*'], ['jshint', 'scripts']);
  gulp.watch(['bower.json'], ['wiredep']);
  gulp.watch('**/*.php', function() {
    browserSync.reload();
  });
});

这是启动“gulp watch”命令后的终端输出:

gulp watch
[12:46:32] Using gulpfile ~/Dropbox/_sites/mywebsite/wp-content/themes/mywebsitetheme/gulpfile.js
[12:46:32] Starting 'watch'...
[12:46:37] Finished 'watch' after 4.26 s
[BS] Proxying: http://mywebsite:8888
[BS] Now you can access your site through the following addresses:
[BS] Local URL: http://localhost:8888
[BS] External URL: http://192.168.22.168:8888

结果 browsersync 打开,使用我的默认浏览器,url http://localhost:8888

我现在需要的是,基本上,生成的 url(由浏览器打开)是http://mywebsite:8888

【问题讨论】:

    标签: wordpress browser-sync


    【解决方案1】:

    感谢 Bower 社区成员 (github issue) 解决了问题 我只需要删除任何配置选项并在结束标记之前添加下面的 sn-p:

    <script type='text/javascript' id="__bs_script__">//<![CDATA[
        document.write("<script async src='//HOST:PORT/browser-sync/browser-sync-client.2.1.0.js'><\/script>".replace(/HOST/g, location.hostname).replace(/PORT/g, location.port));
    //]]></script>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-07-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-06-16
      • 1970-01-01
      • 2013-05-01
      • 1970-01-01
      相关资源
      最近更新 更多