build views to javascript file

This commit is contained in:
MaysWind
2016-08-01 22:15:08 +08:00
parent daf41028f8
commit 042e5040f7
3 changed files with 12 additions and 8 deletions

View File

@@ -22,6 +22,14 @@ gulp.task('scripts', function () {
.pipe(reload({stream: true}));
});
gulp.task('views', function () {
return gulp.src([
'src/views/**/*.html'
]).pipe($.htmlmin({collapseWhitespace: true}))
.pipe($.angularTemplatecache({module: 'ariaNg', filename: 'views/templates.js', root: 'views/'}))
.pipe(gulp.dest('.tmp/scripts'));
});
gulp.task('lint', function () {
return gulp.src([
'src/scripts/**/*.js'
@@ -32,7 +40,7 @@ gulp.task('lint', function () {
.pipe(gulp.dest('src/scripts'));
});
gulp.task('html', ['styles', 'scripts'], function () {
gulp.task('html', ['styles', 'scripts', 'views'], function () {
return gulp.src('src/*.html')
.pipe($.useref({searchPath: ['.tmp', 'src', '.']}))
.pipe($.if('js/*.js', $.replace(/\/\/# sourceMappingURL=.*/g, '')))
@@ -49,12 +57,6 @@ gulp.task('langs', function () {
.pipe(gulp.dest('dist/langs'));
});
gulp.task('views', function () {
return gulp.src('src/views/**/*')
.pipe($.htmlmin({collapseWhitespace: true}))
.pipe(gulp.dest('dist/views'));
});
gulp.task('images', function () {
return gulp.src('src/imgs/**/*')
.pipe(gulp.dest('dist/imgs'));
@@ -114,7 +116,7 @@ gulp.task('serve:dist', function () {
});
});
gulp.task('build', ['lint', 'html', 'langs', 'views', 'images', 'fonts', 'extras'], function () {
gulp.task('build', ['lint', 'html', 'langs', 'images', 'fonts', 'extras'], function () {
return gulp.src('dist/**/*').pipe($.size({title: 'build', gzip: true}));
});