类似的问题已经问过几次了,但没有一个答案对我有用。我正试图将BrowserSync设置为代理服务器,代理服务器为 localhost:8888
为。我的gulpfile来自Foundation Framework的ZURB模板。
gulpfile.babel.js
import gulp from 'gulp';
import browser from 'browser-sync';
// Other Gulp functions
function server(done) {
browser.init({
proxy: 'localhost:8888'
}, done);
}
function reload(done) {
browser.reload();
done();
}
function watch() {
gulp.watch(PATHS.assets, copy);
gulp.watch('templates/**/*.html').on('all', gulp.series(browser.reload));
// Other gulp tasks
}
运行Gulp显示,BrowserSyxnc正在进行代理。
[Browsersync] Proxying: http://localhost:8888
[Browsersync] Access URLs:
-----------------------------------
Local: http://localhost:3000
External: http://10.0.0.113:3000
-----------------------------------
UI: http://localhost:3001
UI External: http://localhost:3001
我试了一下 http:/localhost:8888 和127.0.0.1:8888,没有用。我的文件结构。
gulpfile.babel.js
/src (asset source)
/web (dist location)
/templates (Craft CMS templates, all .html files)
Gulp里的其他东西都很正常 只是无法让代理重载或注入样式
现在工作与此更新的服务器功能。
function server(done) {
browser.init({
port: '8890',
proxy: 'localhost:8888',
reloadOnRestart: true
}, done);
}
进入 localhost:8890
哗啦