yeoman / generator-webapp

A gulp.js generator for modern webapps
3.77k stars 708 forks source link

bower install --save not added to build #705

Closed bogdancss closed 6 years ago

bogdancss commented 6 years ago

Added a new 3rd party lib using bower install --save some-lib.js. This adds it to the bower.json file but that's it. I can add it manually to index.html:

<!-- build:js scripts/vendor.js -->
<!-- bower:js -->
<script src="/bower_components/jquery/dist/jquery.js"></script>
<script src="/bower_components/modernizr/modernizr.js"></script>
<script src="/bower_components/some-lib/dist/some-lib.min.js"></script>
<!-- endbower -->
<!-- endbuild -->

As soon as I run gulp build, gulp wiredep or gulp build, it disappears from index and it does not get included in the build.

I have no changes to the default config.

muhamed87 commented 6 years ago

Try running the following command to install a library and include it in the devDependencies: bower install --save-dev some-lib.js

Then check it after running the gulp build, gulp wiredep or even the gulp serve

bogdancss commented 6 years ago

nope - tried that as well. After installing a lib with --save-dev has the same result as with --save. Running any of the build, wiredep or serve commands, removes the path to the js file from <!-- build:js scripts/vendor.js --> <!-- bower:js --> section.

After building, I run gulp serve:dist and check the vendor.js file - the new lib is not there either

muhamed87 commented 6 years ago

You can try a workaround, by adding the library manually after the <!-- endbower --> and before the <!-- endbuild -->

bogdancss commented 6 years ago

nice - that worked. thank you. Is there a way to modify the gulpfile to add the path to the new lib automatically to the index?

muhamed87 commented 6 years ago

could you please tell about which library you need to include, some of the libraries have an issue that the bower not include even if it is included in the bower.json file, and this may require an update at the library bower json file itself in the bower_components folder

bogdancss commented 6 years ago

it's ShuffleJS. I checked the lib folder and there is no bower.json file, however, there is a .bower.json (preceding dot) with these contents:

{
  "name": "shufflejs",
  "homepage": "https://github.com/Vestride/Shuffle",
  "version": "5.0.3",
  "_release": "5.0.3",
  "_resolution": {
    "type": "version",
    "tag": "v5.0.3",
    "commit": "068c8acf9fe4ae6d5de6b2ffe16f6ededc84d14c"
  },
  "_source": "https://github.com/Vestride/Shuffle.git",
  "_target": "^5.0.3",
  "_originalSource": "shufflejs",
  "_direct": true
}
muhamed87 commented 6 years ago

All bower components installed is injected using the gulp wiredep task.

some components bower json files should be updated, please check that issue and how the developer make the workaround solution by updating the component bower json file https://github.com/yeoman/generator-angular/issues/1325