From 042e5040f722caa2b4bac65ae2c422ebe6b2c8fe Mon Sep 17 00:00:00 2001 From: MaysWind Date: Mon, 1 Aug 2016 22:15:08 +0800 Subject: [PATCH] build views to javascript file --- gulpfile.js | 18 ++++++++++-------- package.json | 1 + src/index.html | 1 + 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index b8b72b7..632a5c7 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -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})); }); diff --git a/package.json b/package.json index e39f5e1..5729695 100644 --- a/package.json +++ b/package.json @@ -7,6 +7,7 @@ "browser-sync": "^2.2.1", "del": "^1.1.1", "gulp": "^3.9.0", + "gulp-angular-templatecache": "^2.0.0", "gulp-autoprefixer": "^3.0.1", "gulp-cssnano": "^2.0.0", "gulp-eslint": "^2.0.0", diff --git a/src/index.html b/src/index.html index 9a2bac6..5e8ed86 100644 --- a/src/index.html +++ b/src/index.html @@ -331,6 +331,7 @@ +