Skip to content

Instantly share code, notes, and snippets.

@pedroxs
Created April 22, 2015 00:39
Show Gist options
  • Save pedroxs/aa2d60248819333a79a5 to your computer and use it in GitHub Desktop.
Save pedroxs/aa2d60248819333a79a5 to your computer and use it in GitHub Desktop.
Frontend dependency management with auto import
{
"name": "myApp",
"private": "true",
"devDependencies": {
"ionic": "driftyco/ionic-bower#1.0.0-rc.2"
},
"dependencies": {
"ngCordova": "~0.1.14-alpha",
"restangular": "~1.5.1"
},
"overrides": {
"angular": {
"ignore": true
}
}
}
var gulp = require('gulp');
var inject = require('gulp-inject');
var bowerFiles = require('main-bower-files');
gulp.task('watch', function() {
gulp.watch(paths.sources, ['inject']);
});
gulp.task('inject', function () {
var target = gulp.src('./www/index.html');
// It's not necessary to read the files (will speed up things), we're only after their paths:
var vendor = gulp.src(bowerFiles(), {read: false, base: './www/lib'});
var sources = gulp.src(['./www/js/**/*.js', './www/css/**/*.css'], {read: false});
return target
.pipe(inject(vendor, {name: 'bower', relative: true}))
.pipe(inject(sources, {relative: true}))
.pipe(gulp.dest('./www'));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment