admin管理员组文章数量:1242825
I want to try using gulp and I've made a simple project similar to this example
what I want to do is to serve the project using different port, I've tried to follow this costum-port example
and my gulpfile.js looks like this :
var gulp = require('gulp');
var browserSync = require('browser-sync');
var livereload = require('gulp-livereload');
var reload = browserSync.reload;
// watch files for changes and reload
gulp.task('serve', function() {
livereload.listen(1234);
browserSync({
server: {
baseDir: 'app',
}
});
gulp.watch(['*.html', 'styles/**/*.css', 'scripts/**/*.js'], {cwd: 'app'}, reload);
});
I also try to add port in server :{porrt : 9999, baseDir:'app'}
but the result end up with the default port which is 3000.
Is it possible to change the port? Thanks.
I want to try using gulp and I've made a simple project similar to this example
what I want to do is to serve the project using different port, I've tried to follow this costum-port example
and my gulpfile.js looks like this :
var gulp = require('gulp');
var browserSync = require('browser-sync');
var livereload = require('gulp-livereload');
var reload = browserSync.reload;
// watch files for changes and reload
gulp.task('serve', function() {
livereload.listen(1234);
browserSync({
server: {
baseDir: 'app',
}
});
gulp.watch(['*.html', 'styles/**/*.css', 'scripts/**/*.js'], {cwd: 'app'}, reload);
});
I also try to add port in server :{porrt : 9999, baseDir:'app'}
but the result end up with the default port which is 3000.
Is it possible to change the port? Thanks.
Share Improve this question edited Jun 20, 2020 at 9:12 CommunityBot 11 silver badge asked Apr 30, 2016 at 3:29 Gujarat SantanaGujarat Santana 10.6k17 gold badges55 silver badges75 bronze badges 4-
Why do you use both
browser-sync
andgulp-livereload
? – qtuan Commented Apr 30, 2016 at 3:54 -
Hmm still new here, I thought
gulp-livereload
will change the port ? so I use that. – Gujarat Santana Commented Apr 30, 2016 at 3:58 - 2 You mean BrowserSync different port – Ben Racicot Commented Apr 8, 2017 at 16:48
- @BenRacicot Yup yo're right. Back then I don't know about it. You could have improve the question though. Thanks for pointing it out. – Gujarat Santana Commented Apr 8, 2017 at 22:09
2 Answers
Reset to default 10Use the port
option.
browserSync({
port: 9999,
server: {
baseDir: 'app',
}
});
port
is a direct option of BrowerSync, not a sub-option under server
option.
Use ui object of browser-sync option for changing default port
var gulp = require('gulp');
var browserSync = require('browser-sync');
var livereload = require('gulp-livereload');
var reload = browserSync.reload;
// watch files for changes and reload
gulp.task('serve', function() {
livereload.listen(1234);
browserSync({
server: {
baseDir: 'app',
},
port: 8080
});
gulp.watch(['*.html', 'styles/**/*.css', 'scripts/**/*.js'], {cwd: 'app'}, reload);
});
本文标签: javascriptBrowsersync serve command with different portStack Overflow
版权声明:本文标题:javascript - Browser-sync serve command with different port - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1740108242a2225715.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论