gpt4 book ai didi

javascript - gulp-connect 根作为数组

转载 作者:搜寻专家 更新时间:2023-11-01 00:08:10 24 4
gpt4 key购买 nike

在 gulp-connect 文档中,它说 options.root 可以是数组或字符串。

我有一个构建目录,我想用作我的根目录,但我还有一个(单独的)源目录,我的所有源映射都指向该目录。我能否利用此 options.root 数组语法来为两个目录提供服务?

我试过了

root: ['build', 'sources']

但这导致只能通过服务器访问 build。我在这里遗漏了什么吗?

最佳答案

实际上它确实有效,但是根页面在索引页面中仅显示第一个根。

我所做的是创建目录 a,其中包含一个简单的 index.html 文件:

<script src="b.js"></script>

然后在目录 b 中,我将 b.js 放在一行中:

alert("you found me!!!")

我启动了以下 gulpfile:

var gulp = require('gulp'),
connect = require('gulp-connect');

gulp.task('default', function () {
connect.server({
root: ['a', 'b'],
port: 8080,
livereload: true
});
});

并加载 localhost:8080/index.html 并且...弹出警报

关于javascript - gulp-connect 根作为数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24393765/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com