我来自笨拙的背景.设置Web服务器就像这样简单grunt connect.
我会将以下代码放在我的grunt文件中并运行grunt connect:
grunt.initConfig({
// fire up the local server
connect: {
server: {
options: {
port: 9778, //port to host on
livereload: 35729,
hostname: '0.0.0.0', //the hostname
base: 'out/' //the relative path from grunt file to base folder of web app
}
}
}
});
grunt.loadNpmTasks('grunt-contrib-connect');
我的情况发生了变化,因为我不得不迁移到gulp.但我不能让它干涸.可能是因为我的背景.我正在使用gulp-webserver.并添加了我的gulp文件如下:
gulp.task('serve', function() {
gulp.src('app')
.pipe(webserver({
path:'dist',
port:'9090',
livereload: true,
directoryListing: true,
open: true
}));
});
当我导航到时localhost:9090,我收到了回复:cannot GET /
我究竟做错了什么?不是gulp文件的路径相对路径?我应该传递给gulp.src谁?如果有人能给我一个关于哪里看的话,这将是一个很大的帮助.
编辑1
我的gulpfile,src文件夹和构建后的文件夹,即dist文件夹都在同一级别.
??? src // my raw application folder
??? dist // application folder after building
| .
| .
| ??? index.html
??? gulpfile.js