gulp创建的服务器怎么访问文件,使用gulp设置本地Web服务器

我来自笨拙的背景.设置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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值