Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/436.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何使用gulp serve服务构建目录之外的组件_Javascript_Build_Gulp - Fatal编程技术网

Javascript 如何使用gulp serve服务构建目录之外的组件

Javascript 如何使用gulp serve服务构建目录之外的组件,javascript,build,gulp,Javascript,Build,Gulp,使用该插件,我在rootbin/dev/为我的应用程序提供服务,我的文件夹结构如下: bower_components/ angular/ bin/ dev/ scripts/ content/ css/ index.html index.html中对bower\u组件的注入引用如下所示: “../../bower\u components/angular/angular.js” 运行gulp-serve时,导航到应用程序时不包括组件,例如,

使用该插件,我在root
bin/dev/
为我的应用程序提供服务,我的文件夹结构如下:

bower_components/
    angular/
bin/
  dev/
    scripts/
    content/
        css/
    index.html
index.html
中对
bower\u组件的注入引用如下所示:

“../../bower\u components/angular/angular.js”

运行
gulp-serve
时,导航到应用程序时不包括组件,例如,
“../../bower\u-components/angular/angular.js”

以下是我的吞咽任务:

gulp.task('service',plugins.service('bin/dev/')

如何为我的应用程序提供服务并在构建目录之外包含资产?

我选择使用插件

我能够使用中间件选项在目录外提供文件,如下所示:

var webserver = require('gulp-webserver');
var serveStatic = require('serve-static');

gulp.task('serve', function () {
    gulp.src('./bin/dev/')
        .pipe(plugins.webserver({
            middleware: [
                serveStatic(__dirname)
            ]
        }));
});
其中
\uuu dirname
是路径
/
的根

然后,我可以简单地将脚本注入
index.html
中,使用如下方法:

“bower\u组件/angular/angular.js”