【问题标题】:Wiredep Gulp Dependency Injection Not workingWiredep Gulp 依赖注入不起作用
【发布时间】:2017-08-27 23:59:39
【问题描述】:

这是我的任务

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'));
});

这些是我 bower.json 中的依赖项

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

当我在命令行中运行“gulp injection”时,它似乎可以工作,但我的依赖项没有出现在 index.html 中。

【问题讨论】:

    标签: dependency-injection gulp bower wiredep


    【解决方案1】:

    我尝试使用您发布的完全相同的 gulp 任务进行重现,并且所有文件都已正确注入。

    我没有看到您的 index.html,但检查了您的任务,与我的唯一不同的是 bower 目录。您确定 ./public/lib 也设置在您的 bower.json 文件中吗?

    另外,您是否在 html 中添加了这些标签?

    
    

    
    

    这就是我的 index.html 的样子:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-06-12
      • 2023-02-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多