Skip to content

Instantly share code, notes, and snippets.

@subtubes-io
Last active August 29, 2015 14:14
Show Gist options
  • Save subtubes-io/63cf6fc1baeb196ba184 to your computer and use it in GitHub Desktop.
Save subtubes-io/63cf6fc1baeb196ba184 to your computer and use it in GitHub Desktop.
Gulp task to inject modular angularjs and bower dependencies
var gulp = require('gulp');
var inject = require("gulp-inject");
var wiredep = require('wiredep').stream;
gulp.task('default', function () {
var target = gulp.src('./app/index.html');
var sources = gulp.src([
'./app/scripts/**/*.module.js',
'./app/scripts/**/*.js',
'./app/scripts/app.js'
], {read: false});
return target.pipe(inject(sources, {relative: true}))
.pipe(gulp.dest('./app'));
});
gulp.task('bower', function () {
gulp.src('./app/index.html')
.pipe(wiredep({}))
.pipe(gulp.dest('./app'));
});
<!DOCTYPE html>
<html data-ng-app="app">
<head>
<title>My index</title>
<!-- inject:css -->
<!-- endinject -->
<!-- bower:css -->
<!-- endbower -->
</head>
<body>
<div humble></div>
<!-- bower:js -->
<script src="lib/angularjs/angular.js"></script>
<!-- endbower -->
<!-- inject:js -->
<script src="scripts/_common/common.module.js"></script>
<script src="scripts/login/login.module.js"></script>
<script src="scripts/app.js"></script>
<script src="scripts/login/directives/humble.js"></script>
<!-- endinject -->
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment