Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Grunt deleting index.html content

Tags:

gruntjs

yeoman

I've noticed on a couple projects with Yeoman that when I run any of the the grunt build, grunt serve commands, content (script tags, link tags, the like) get deleted from my index.html file. Any ideas as to why this happens? And how to fix it. Seems to be happening with imports from my bower_components folder especially, but I've also had instances where the font-awesome cdn was deleted as well.

If it makes a difference, I'm developing for AngularJS using Yeoman.

like image 684
parsenz Avatar asked Dec 01 '25 10:12

parsenz


1 Answers

I encountered this sometimes. The changed parts are enclosed in

<!-- bower:css -->
<link rel="stylesheet" href="bower_components/......" />
......
<!-- endbower -->

or

<!-- bower:js -->
<script src="bower_components/....."></script>
......
<!-- endbower -->

The content in bower:js/css tag are generated from bower.json, so if the js/css files are not listed in bower.json, it will be removed from bower:js/css.

The good practice is to use bower install --save or bower install --save-dev to install the dependency, it will update the bower.json automatically.

like image 145
xiaoboa Avatar answered Dec 04 '25 06:12

xiaoboa



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!