George Edwards
George Edwards

Reputation: 9229

Managing Dependencies in SailsJS

How can I manage dependencies in a Sails.JS based project. There is a really neat feature which automatically links assets from the assets folder into the relevant templates, however, to get these files, e.g Angular, Bootstrap, Material-Design etc. I like to run bower / npm install. But then the resources are in the bower_compnents file and can't be linked to. How can I work around this to get file installed by package managers to be included in Sails.JS's default mechanism?

Upvotes: 3

Views: 724

Answers (1)

Angelos Veglektsis
Angelos Veglektsis

Reputation: 432

You have the option to change the location of the bower components with a .bower.rc file.

Example .bower.rc

{
    "directory": "assets/components/"
}

It is not a good idea to automatically link components, there are many .js/.css files that must not included together (eg. lib_name.js and lib_name.min.js).

You have to include them manually like this (tasks/pipeline.js)

  var jsFilesToInject = [
  'components/lodash/lodash.js',    
  'components/moment/moment.js',
  'components/moment/locale/el.js',
  'components/angular-moment/angular-moment.js',

  'components/re-tree/re-tree.min.js',
  'components/ng-device-detector/ng-device-detector.js',

  // Load sails.io before everything else
  'js/dependencies/extend.js',
  'js/dependencies/sails.io.js',

  // Dependencies
  //'js/dependencies/**/*.js',


  'js/my-app-bootstrap.js',

   // load my controllers
  'js/angular/**/*.js',

  'js/my-app.js',
];

Upvotes: 3

Related Questions