Wiredep + Gulp将不会生成任何脚本标记和path

我一直试图让wiredepgulp生成我的脚本标签和path的脚本加载(和 – 保存开发)通过鲍尔,如无数的教程中所示,但无论我做什么,它将复制HTML源文件很好,但不会注入脚本标签和path。

我现在只想连接Bower.json文件,所以我删除了部分处理css文件的示例脚本,大部分示例中都包含注入部分。

gulpfile.js :(仅限摘要)

gulp.task( 'bower', function () { var wiredep = require( 'wiredep' ).stream; return gulp.src( './src/index.html' ) .pipe( wiredep( { cwd : './src', directory: './bower_components/', bowerJson: require( './bower.json' ), } ) ) .pipe( gulp.dest( './build' ) ); } ); 

bower.json文件

 { "name": "SomeProject", "description": "", "ignore": [ "**/.*", "node_modules", "bower_components", "test", "tests" ], "devDependencies": { "angular-mocks": "~1.4.9", "angular": "~1.4.9", "jquery": "components/jquery#^2.2.0", "angular-aria": "^1.5.0" } } 

.bowerrc文件

 { "directory" : "bower_components" } 

index.html文件最后几行

  </div> </div> <!--bower:js--> <!--endbower--> <script src="js/app.js" type = "text/javascript"></script> </body> </html> 

所以,我运行它,它将index.html文件复制到正确的位置,但在html文件中的输出是完全相同的input。

结果:

  </div> </div> <!--bower:js--> <!--endbower--> <script src="js/app.js" type = "text/javascript"></script> </body> </html> 

我错过了什么?

我试过的东西没有任何区别:

  • 从和添加或删除空格
  • 在gulpfile.js和gulp.task的头部需要wiredep
  • 调用wiredep有或没有选项
  • 尝试不同的select和不同的path
  • 使用variables来源和目的地,而不是inlineglobs
  • 使用尾随斜杠还是不
  • 使用./或不
  • 使用一个空的.bowerrc文件与上面的一个
  • 重命名吞噬任务
  • 删除bower.json文件中的“忽略”部分

主要的问题在于你的bower.json文件。 将devDependencies更改为dependencies ,因为这是wiredep期望的。 它没有find它正在寻找什么。 :

bower.json

 { "name": "SomeProject", "description": "", "ignore": [ "**/.*", "node_modules", "bower_components", "test", "tests" ], "dependencies": { "angular-mocks": "~1.4.9", "angular": "~1.4.9", "jquery": "components/jquery#^2.2.0", "angular-aria": "^1.5.0" } } 

另外,你的gulpfile的wiredep不需要任何参数

gulpfile.js

 gulp.task( 'bower', function () { var wiredep = require( 'wiredep' ).stream; return gulp.src( './src/index.html' ) pipe( wiredep( { // cwd : './src', // <--------------- TAKE THIS LINE OUT // directory: './bower_components/', /// <--- AND REMOVE ALL THESE // bowerJson: require( './bower.json' ) /// <--- (UNLESS YOUR GULPFILE IS IN ANOTHER DIRECTORY) // onError : function(err) { /// <--- I used these for debugging. Uncomment them and you'll see things be more verbose when you call this gulp task. // console.log("Wiredep error: "+err); // }, // onFileUpdated : function (filePath) { // console.log('File path was updated: ' + filePath); // }, // onPathInjected : function (fileObject) { // console.log('Path injected: ' + JSON.stringify(fileObject)); // } })) .pipe( gulp.dest( './build' ) ); } );