Skip to content

Adding Dependencies to the Project

connercowling edited this page Apr 14, 2015 · 3 revisions

1) Use Bower to install

It is common for libraries to be registered with Bower. Registration allows the library to be installed with a short bower install command. cd into the branchr-client directory and run the bower install command:

bower install --save <dependency-name>

The --save argument adds the dependency to the project's bower.json file. You should see the dependency listed within the dependencies object within bower.json.

2) Include the dependency in the gulpfile

Next we need to make gulp aware of the dependency by adding it to the function below.

gulp.task('bower-copy-js', ['bower'], function() {
    var deps = [
        'es6-module-loader/dist/es6-module-loader.js*',
        'traceur/traceur.min*',
        'system.js/dist/system.js*',
        'vue/dist/vue.min*',
        'director/build/director.min.js',
        'furtive/scss/all.scss',
        <path-to-dependency-name>
    ];
    return gulp.src(deps.map(function(dep) {
        var a = path.join(paths.bower.src, dep);
        console.log(a);
        return a;
    }))
        .pipe(gulp.dest(paths.js.dest))
});

3) Install the new dependency in the project

While still inside of the branchr-client, run npm install.

4) Import the dependency using ES6 syntax (if appropriate)