-
Notifications
You must be signed in to change notification settings - Fork 2
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
vendorssection to thestassetsconfig"stassets": { "vendors": { "prefix": ["./node_modules"], "js": ["moment/min/moment.min.js"] } } -
Use moment through the global
momentvariable. (In an angular project, the recommended best practice is to wrap that variable in a service.)
- The
prefixkey is an array of directories to look in. For instance, when mixing bothnode_modulesandbowerdependencies, theprefixkey could be[ "./node_modules", "./components" ] - The
jsandcsskeys are arrays of files to concatenate in their respectivevendors.jsandvendors.cssfiles. Theprefixdirectories will be searched in order for these paths, and the first match will be returned.