Wiredep Gulp Dependency Injection Not working

288 views Asked by At

This is my gulp task

gulp.task('inject', function() {
  var wiredep = require('wiredep').stream;
  var options = {
    bowerJson: require('./bower.json'),
    directory: './public/lib'
  };
  return gulp.src('./src/views/*.html')
  .pipe(wiredep(options))
  .pipe(gulp.dest('./src/views'));
});

And these are the dependencies in my bower.json

  "dependencies": {
    "bootstrap": "^3.3.7",
    "font-awesome": "^4.7.0"
  }

When I run 'gulp inject' in the command line it appears to work but my dependencies don't appear in index.html.

1

There are 1 answers

0
Bruno Poeta On

I've tried to reproduce with the exact same gulp task you posted and all files were injected correctly.

I'm not seeing your index.html, but checking your task, the only thing different from mine is the bower directory. Are you sure the ./public/lib is also set on your bower.json file?

Also, are you adding these tags on your html?

<!-- bower:css -->
<!-- endbower -->

and

<!-- bower:js -->
<!-- endbower -->

This is what my index.html looks like:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <!-- bower:css -->
    <!-- endbower -->
    <title>Wiredep test</title>
</head>
<body>

<!-- bower:js -->
<!-- endbower -->
</body>
</html>