I was wondering what would be the best practice to share common libraries and own modules between multiple angularJS projects.
Let's assume that I'm working on two different projects. Both rely on libraries like angularJS, bootstrap etc.
I have a file structure like below:
- Project 1
- index.html
- css
- js
- module A
- module B
- lib
- angular
- bootstrap
- Project 2
- index.html
- css
- js
- module B
- module X
- lib
- angular
- bootstrap
So I was thinking about just creating another directory with all the shared components so that I get sth. like:
- Shared
- angular
- bootstrap
- module B
- Project 1
- index.html
- css
- js
- module A
- Project 2
- index.html
- css
- js
- module X
I have module B written like:
angular.module("moduleB", [])
.service("SB", [function () {/*functionality here*/}]);
.factory("FB", [function () {/*functionality here*/}]);
and would then include it in my Project 1/2 as dependency like:
angular.module("project1", ["moduleB"]);
to achieve this approach.
Would that be the best way? What could be an alternative?