连接到在vagrant box内运行的browsersync有什么提示吗?
当它检测到css更改时,我会自动启动浏览器同步 输出看起来像连接到在vagrant box内运行的browsersync有什么提示吗?,vagrant,gulp,browser-sync,gulp-sass,Vagrant,Gulp,Browser Sync,Gulp Sass,当它检测到css更改时,我会自动启动浏览器同步 输出看起来像 [BS] [info] Proxying: http://dev.local [BS] Access URLs: ------------------------------------- Local: http://localhost:3000/cw External: http://10.0.2.15:3000/cw -------------------------------------
[BS] [info] Proxying: http://dev.local
[BS] Access URLs:
-------------------------------------
Local: http://localhost:3000/cw
External: http://10.0.2.15:3000/cw
-------------------------------------
UI: http://localhost:3001
UI External: http://10.0.2.15:3001
-------------------------------------
在浏览器中,我可以访问dev.local
,dev.local/cw
和dev.local:3001
,但不能dev.local:3000
或dev.local:3000/cw
当我尝试连接到dev.local:3000或dev.local:3000/cw时,浏览器只是挂起,等待最终超时
我想我可能在VM中有端口转发问题,所以我转发了Vagrant文件中的端口浏览器同步使用
config.vm.network "forwarded_port", guest: 3000, host: 3000
但还是没有运气
myGulpfile.js
var gulp = require('gulp');
var gutil = require('gulp-util');
var sass = require('gulp-sass');
var watch = require('gulp-watch');
var shell = require('gulp-shell');
var notify = require('gulp-notify');
var browserSync = require('browser-sync');
var sourcemaps = require('gulp-sourcemaps');
var uglify = require('gulp-uglify');
gulp.task('sass', function () {
return gulp.src('./scss/**/*.scss')
.pipe(sourcemaps.init())
.pipe(sass({
noCache: true,
outputStyle: "compressed",
lineNumbers: false,
loadPath: './css/*',
sourceMap: true
}))
.pipe(sourcemaps.write('./maps'))
.pipe(gulp.dest('./css'))
.pipe(notify({
title: "SASS Compiled",
message: "All SASS files have been recompiled to CSS.",
onLast: true
}));
});
gulp.task('watch', function() {
browserSync({
proxy: "dev.local",
startPath: "cw"
});
// watch scss, js, and tpl files and clear drupal theme cache on change, reload browsers
gulp.watch(['scss/**/*.scss', 'js-src/**/*.js', 'templates/**/*.tpl.php'], function() {
gulp.run('sass');
}).on("change", browserSync.reload);
});
gulp.task('default', ['watch']);
你知道我为什么不能通过网站连接到浏览器同步吗?在哪里可以找到解决方案?我在同一条船上,有点放弃了。但实际上我现在正在做一个项目,可以真正使用这个。所以我今天就来看看,希望有什么要更新的吗?@Uma我希望如此。我知道的唯一解决方案是在主机上安装node并运行browsersync不幸的是,您在哪里可以找到解决方案?我在同一条船上,有点放弃了。但实际上我现在正在做一个项目,可以真正使用这个。所以我今天就来看看,希望有什么要更新的吗?@Uma我希望如此。我知道的唯一解决方案是在主机上安装node并运行browsersync