-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.js
41 lines (34 loc) · 1.33 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
var gulp = require('gulp'),
extend = require('extend'),
htmlmin = require('gulp-htmlmin'),
templateCache = require('gulp-angular-templatecache'),
elixir = require('laravel-elixir'),
gulpIf = elixir.Plugins.if,
sourcemap = elixir.Plugins.sourcemaps,
config = elixir.config;
elixir.extend('ngTemplateCache', function(src, output, basedir, options) {
options = extend(true, {
enabled: {
htmlmin: config.production
},
templateCache: {
standalone: true
},
htmlmin: {
collapseWhitespace: true,
removeComments: true
}
}, options);
var paths = new elixir.GulpPaths()
.src(src || '/**/*.html', basedir || config.assetsPath + '/templates')
.output(output || config.get('public.js.outputFolder'));
new elixir.Task('ngTemplateCache', function() {
return gulp.src(paths.src.path)
.pipe(gulpIf(config.sourcemaps, sourcemap.init()))
.pipe(gulpIf(options.enabled.hmtlmin, htmlmin(options.htmlmin)))
.pipe(templateCache(options.templateCache))
.pipe(gulpIf(config.sourcemaps, sourcemap.write('.')))
.pipe(gulp.dest(paths.output.baseDir))
.pipe(new elixir.Notification('Angular templatecache generated.'));
}).watch(paths.src.path);
});