Séb*_*uel 5 apache macos mamp gulp browser-sync
我知道 SO 和 GitHub 上有很多类似的问题,但没有一个适合我的情况。
我需要一个项目来使用 gulp + browsersync 和 apache vhost(使用 MAMP PRO 5.5 创建)。
Gulp 正在工作(它完成了我需要的所有任务)。Browsersync 已设置,但它在与 MAMP 使用的端口不同的端口上打开我的网站。我已经使用默认端口和 Mamp 默认端口进行了测试。Browsersync 仍然使用正确的 url 但不正确的端口打开网站。
我知道我不能使用相同的端口,但如何设置 Browsersync ?
这是我的吞咽相关部分:
gulp.task('browser-sync', ['sass', 'scripts'], function () {
browserSync.init({
open: 'external',
host: 'my-domain.dev',
proxy: 'my-domain.dev',
https: {
key: "/Users/path-to-custom-certificate/my-domain.dev.key",
cert: "/Users/path-to-custom-certificate/my-domain.dev.crt"
},
//port: 443, // If I try same port as MAMP, Browsersync increments this port ex 444
browser: "google chrome"
});
});
Run Code Online (Sandbox Code Playgroud)
也许可以在 APACHE 中配置一些东西?
我犹豫是否要删除我的问题,但以防万一它有帮助:
最后,看来我的 Browsersync 代码是正确的。当我运行 gulp 时,它使用 Browsersync 默认端口打开错误的 url:
https://my-domain.dev:3000
Run Code Online (Sandbox Code Playgroud)
但是,当我打开 apache 中设置的正确 url ( my-domain.dev) 时,Browsersync 已连接并重新加载该页面。