Grunt wiredep 如何控制wiredep如何生成bower文件路径以及如何控制添加/删除哪些文件

Grunt wiredep 如何控制wiredep如何生成bower文件路径以及如何控制添加/删除哪些文件,grunt-wiredep,Grunt Wiredep,我的应用程序有如下目录 app->appName->index.html(js、css) 由于某种原因,这个appName包装器文件夹搞砸了 { dest: '.tmp/concat/scripts/vendor.js', src: [ '../bower_components/es5-shim/es5-shim.js', '../bower_components/angular/angular.js', '../bower_com

我的应用程序有如下目录

app->appName->index.html(js、css)

由于某种原因,这个appName包装器文件夹搞砸了

{ dest: '.tmp/concat/scripts/vendor.js',
      src: 
       [ '../bower_components/es5-shim/es5-shim.js',
         '../bower_components/angular/angular.js',
         '../bower_components/json3/lib/json3.js',
         '../bower_components/angular-resource/angular-resource.js',
         '../bower_components/angular-cookies/angular-cookies.js',
         '../bower_components/angular-sanitize/angular-sanitize.js',
         '../bower_components/angular-animate/angular-animate.js',
         '../bower_components/angular-touch/angular-touch.js',
         '../bower_components/angular-route/angular-route.js' ] },
如果目录如下所示,则会生成以下内容

app->index.html(js、css)


wiredep确实改变了index.html的脚本内容,我如何控制这个流程?有时它会从脚本[src]

中去除角消毒,您是否尝试将
cwd
添加到
选项

例:


您应该使用wiredep的替换选项:

wiredep(
    {
        fileTypes: {
            html: {
                replace: {
                    js: '<script src="/app/appName/{{filePath}}"></script>'
                }
            }
        }
    })
wiredep(
{
文件类型:{
html:{
替换:{
js:'
}
}
}
})
将产生:

<script src="/app/appName/bower_components/angular/angular.js"></script>

这是我的gulp设置(相同的原则适用于Grunt,只需将相同的选项传递给它)

您可以在lib/inject-dependencies.js中查看wiredep源代码(行:80~85)

它只是替换你提供的钻头(如果你不给它,也可以不给它)


希望有帮助

我很确定
cwd
选项告诉wiredep在哪里可以找到
bower.json
这是最好的答案这个“替换”对我来说很有效+@Kdawgwilk的评论为1。cwd不适合我。
wiredep(
    {
        fileTypes: {
            html: {
                replace: {
                    js: '<script src="/app/appName/{{filePath}}"></script>'
                }
            }
        }
    })
<script src="/app/appName/bower_components/angular/angular.js"></script>
gulp.task('wiredep' , function()
{
    return gulp.src('./app/index.html')
           .pipe(wiredep({
               'ignorePath': '../'
           }))
          .pipe(gulp.dest('./app'));
});
map(function (filePath) {
    return $.path.join(
      $.path.relative($.path.dirname(file), $.path.dirname(filePath)),
      $.path.basename(filePath)
    ).replace(/\\/g, '/').replace(ignorePath, '');
  }).