Reputation: 22540
I am using gulp-open with gulp in windows 7:
gulp.task('op', function(){
var options = {
uri: 'localhost:8080',
app: 'chrome'
};
gulp.src(__filename)
.pipe(open(options));
});
The index.html file opens with the app when I use app:'Firefox' but when I use the chrome option it opens an empty index.html? How can I fix this?
Upvotes: 4
Views: 6617
Reputation: 654
This is a snippet of my code that solves the issue for me, you can use it to modify yours accordingly:
var gulp = require('gulp');
var liveServer = require('gulp-live-server');
var browserSync = require('browser-sync');
gulp.task('live-server', function(done){
var server = new liveServer('server/main.js');
server.start();
done();
})
gulp.task('serve', gulp.series('live-server', function(done){
browserSync.init(null,{
proxy:"http://localhost:7777",
port:9001,
open: true
})
done();
}));
Upvotes: 1
Reputation: 176
I only added http:// to the uri and it worked for me.
gulp.task('op', function(){
var options = {
uri: 'http://localhost:8080',
app: 'chrome'
};
gulp.src(__filename)
.pipe(open(options));
});
Upvotes: 1
Reputation: 3239
Depending on the OS you need to refer to the chrome app differently in options:
'google-chrome' // Linux
'chrome' // Windows
'google chrome' or 'Google Chrome' // OSX
Refer to section Options.app in the NPM documentation about gulp-open.
Upvotes: 10