How do I connect bower components with sails.js?

前端 未结 5 553
执念已碎
执念已碎 2020-12-07 12:28

I\'d like to be able to install Javascript dependencies through bower and use them in a sails.js app, but I can\'t figure out a way to do this with out just

5条回答
  •  北荒
    北荒 (楼主)
    2020-12-07 13:34

    Sorry for my late.

    I think include bower_components in linker it's a bad idea, because when you will lift sails, everything in it will be copied in .tmp and include in tags. For example, if you have include Angular with bower, you will have two inclusions in your script: one for angular.js and one for angular.min.js. And having both is a mistake.

    Here is my solution on my projects :

    • I have created a folder bower_component in my root directory.
    • I have added this line in my Gruntfile.js in the array files in copy:dev

      { '.tmp/public/linker/js/angular.js': './bower_components/angular/angular.js' }

    And for each files I want to include, I need to manually add a new line in this array. I haven't find an another automatic solution. If someone finds a better solution... ;)

提交回复
热议问题