gulp-ng-inject
I love using gulp-inject. It's a great tool that can take care of including your JavaScript and bower files into your index.html
file.
When working with Angular.js
, I also wanted to include all my modules names as a depedency of my application automatically. So that I don't have to include each module name by hand. gulp-ng-inject
does that for you.
You can also watch files & when they change it can reload the browser for you in combination with gulp-watch and BrowserSync.
Install
npm install gulp-ng-inject --save-dev
Usage
- This is the only depedency you'll need into your
Angular.js
project: 'gulp-ng-inject'
// app/src/main.js angular;
- Create a task to run:
// gulpfile.js var gulp = ;var ngInject = ; gulp;
- Make sure that the module path it's added to your index.html
API
ngInject(fileName, options)
fileName
Type: string
The destination fileName.
options
name
Type: string
The name of the module that you want to use.
modules
Type: array
List of additional modules to include.
Example
var browserSync = ;var gulp = ;var inject = ;var ngInject = ;var watch = ; var config = baseDir: './app/src' jsFiles: './app/src/js/**/*.js' port: 3030 gulp; gulp; gulp; gulp; gulp;
HTML with Inject tags.
<!-- inject:js --><!-- endinject -->