-
Notifications
You must be signed in to change notification settings - Fork 3
Cookbook: Add Vendor Libraries
DavidSouther edited this page Oct 23, 2014
·
1 revision
Additional libraries can be added to a project using any dependency mechanism,
then added to the vendors
key in the stassets
configuration. For instance,
let's add [Moment.js][moment] for date handling.
-
Install the dependency:
$ npm install --save moment
-
Add a
vendors
section to thestassets
config"stassets": { "vendors": { "prefix": ["./node_modules"], "js": ["moment/min/moment.min.js"] } }
-
Use moment through the global
moment
variable. (In an angular project, the recommended best practice is to wrap that variable in a service.)
- The
prefix
key is an array of directories to look in. For instance, when mixing bothnode_modules
andbower
dependencies, theprefix
key could be[ "./node_modules", "./components" ]
- The
js
andcss
keys are arrays of files to concatenate in their respectivevendors.js
andvendors.css
files. Theprefix
directories will be searched in order for these paths, and the first match will be returned.