gulp-ng-templates
Version:
Build all of your angular templates in just one js file using $templateCache provider
100 lines (71 loc) • 2.15 kB
Markdown
//img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=X7BZW864PRHSU)
Build all of your angular templates in just one js file using `$templateCache` provider
```
npm install --save-dev gulp-ng-templates
```
```
yarn add -D gulp-ng-templates
```
```js
var gulp = require('gulp');
var ngTemplates = require('gulp-ng-templates');
gulp.task('templates', ['clean'], function () {
return gulp.src(paths.templates)
.pipe(htmlmin({collapseWhitespace: true}))
.pipe(ngTemplates({
filename: 'templates.js',
module: 'App/templates',
path: function (path, base) {
return path.replace(base, '').replace('/templates', '');
}
}))
.pipe(gulp.dest('public/js'));
});
```
```js
var gulp = require('gulp');
var ngTemplates = require('gulp-ng-templates');
gulp.task('templates', ['clean'], function () {
return gulp.src(paths.templates)
.pipe(ngTemplates('moduleName'))
.pipe(gulp.dest('public/js'));
});
```
gulp-ng-templates ([options](
----
> Change the path of your templates. (See the example above)
> If you not set this option it will automatically replace all of the file base path with nothing.
> Create a new AngularJS module, instead of using an existing one.
> Options to pass to the [html-minifier](https://github.com/kangax/html-minifier) module
```js
{
removeComments: true,
collapseWhitespace: true,
preserveLineBreaks: false,
conservativeCollapse: false,
collapseBooleanAttributes: true,
collapseInlineTagWhitespace: true
}
```
> Provides the module name.
> The template header, the default value is:
```js
angular.module("<%= module %>"<%= standalone %>).run(["$templateCache", function($templateCache) {
```
> The template footer, the default value is:
```js
}]);
```
[![Donate](https: