简体   繁体   English

使用Wiredep在Angular应用中添加Bower软件包

[英]Use wiredep to add bower packages in Angular app

I am relatively new to angular js & gulp. 我对angular js和gulp比较陌生。 I am currently trying ionic framework for mobile apps as well. 我目前也在尝试用于移动应用程序的ionic框架。 I started of with ionic tabs template, I am using bower for js libraries. 我从ionic选项卡模板开始,我在使用js库的Bower。 I am have added a few bower packages in my bower.json file and want to use wiredep to inject those files into my index.html. 我在bower.json文件中添加了一些Bower软件包,并希望使用wiredep将这些文件注入到我的index.html中。 My problem is that when I use wiredep in cli or gulp task it only adds files from two of my packages that I added, but not the ones from ionic. 我的问题是,当我在cli或gulp任务中使用wiredep时,它只会添加我添加的两个软件包中的文件,而不会添加来自ionic的文件。

Extract from index.html 从index.html提取

<!-- ionic/angularjs js -->
<script src="lib/ionic/js/ionic.bundle.js"></script>
<script src="lib/ionic/js/angular/angular-resource.min.js"></script>

<!-- cordova script (this will be a 404 during development) -->
<script src="cordova.js"></script>

<!-- your app's js -->
<script src="js/app.js"></script>

<!-- bower:js -->
<script src="lib/angular/angular.js"></script>
<script src="lib/ng-azure-mobile-service/ng-azure-mobile-service.min.js"></script>
<script src="lib/ng-azure-mobile-service/MobileServices.Web-1.2.5.js"></script>
<!-- endbower -->

You can see that my bower:js section only contains the three files from my bower package not from ionic. 您可以看到我的bower:js部分仅包含来自我的bower包的三个文件,而不包含来自ionic的文件。 In ideal case I must be able to remove the first 3 lines and defend on wiredep to add them for me. 在理想情况下,我必须能够删除前三行并捍卫wiredep以便为我添加它们。

bower.json bower.json

{
  "name": "oz-beauty",
  "private": "true",
  "devDependencies": {
    "ionic": "driftyco/ionic-bower#1.0.0-beta.14"
  },
  "dependencies": {
    "ng-azure-mobile-service": "~1.3.5"
  },
  "overrides": {
    "ionic": {
      "main": ["lib/ionic/js/ionic.bundle.js"]
    }
  }
}

Kindly let me know if I'm missing something. 请让我知道我是否缺少任何东西。

If you use gulp, you can use devDependencies flag of wiredep plugin. 如果使用gulp ,则可以使用wiredep插件的devDependencies标志。

gulp.task('bower', function () {
   gulp.src('./app/index.html')
     .pipe(wiredep({
        devDependencies: true
      }))
     .pipe(gulp.dest('./dest'));
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM