aurelia Aurelia CLI Adding Lodash To A CLI Application


A commonly used utility library is Lodash. To install it into your Aurelia CLI driven application first you need to install it using Npm.

npm install lodash --save

Now in your preferred IDE/code editor open up the following file in your project directory: aurelia_project/aurelia.json and scroll down to the build.bundles section towards the end of the file. We will want to add Lodash to one of the bundles. For this example, we will be adding Lodash into the vendor bundle.

Because Lodash does follow the CommonJS conventions and exports one concatenated file we can easily register it by adding the following object ot the dependencies array:

  "name": "lodash",
  "path": "../node_modules/lodash/lodash.min"

Note that we omited the .js file suffix as those will be automatically appended when resolving the dependency.

Now we can use Lodash by simply importing it, using the ES6 import syntax:

import _ from 'lodash';