Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can bower automatically write <script> tags into index.html?

Tags:

bower

yeoman

I'm using yeoman's backbone generator, and I ran this:

bower install backbone.localStorage -S 

And I manually had to insert this into index.html:

<script src="bower_components/backbone.localStorage/backbone.localStorage.js"></script> 

Is there some way for bower to automatically insert <script> tags? I thought part of the benefit of bower was not having to figure out in which order to include your scripts?

like image 954
CaptSaltyJack Avatar asked Sep 15 '13 16:09

CaptSaltyJack


2 Answers

Just run

grunt bowerInstall  

after bower install

like image 93
mvilrokx Avatar answered Nov 02 '22 17:11

mvilrokx


You can use wiredep to push dependencies into your HTML code from bower. This is the approach used by generator-angular when you run yo angular:

var wiredep = require('wiredep'); wiredep({    directory: 'app/bower_components',    bowerJson: JSON.parse(fs.readFileSync('./bower.json')),    ignorePath: 'app/',    htmlFile: 'app/index.html',    cssPattern: '<link rel="stylesheet" href="{{filePath}}">' }); 
like image 39
Kato Avatar answered Nov 02 '22 17:11

Kato