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})); .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 () { gulp.task('lint', function () {
return gulp.src([ return gulp.src([
'src/scripts/**/*.js' 'src/scripts/**/*.js'
@ -32,7 +40,7 @@ gulp.task('lint', function () {
.pipe(gulp.dest('src/scripts')); .pipe(gulp.dest('src/scripts'));
}); });
gulp.task('html', ['styles', 'scripts'], function () { gulp.task('html', ['styles', 'scripts', 'views'], function () {
return gulp.src('src/*.html') return gulp.src('src/*.html')
.pipe($.useref({searchPath: ['.tmp', 'src', '.']})) .pipe($.useref({searchPath: ['.tmp', 'src', '.']}))
.pipe($.if('js/*.js', $.replace(/\/\/# sourceMappingURL=.*/g, ''))) .pipe($.if('js/*.js', $.replace(/\/\/# sourceMappingURL=.*/g, '')))
@ -49,12 +57,6 @@ gulp.task('langs', function () {
.pipe(gulp.dest('dist/langs')); .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 () { gulp.task('images', function () {
return gulp.src('src/imgs/**/*') return gulp.src('src/imgs/**/*')
.pipe(gulp.dest('dist/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})); return gulp.src('dist/**/*').pipe($.size({title: 'build', gzip: true}));
}); });

View file

@ -7,6 +7,7 @@
"browser-sync": "^2.2.1", "browser-sync": "^2.2.1",
"del": "^1.1.1", "del": "^1.1.1",
"gulp": "^3.9.0", "gulp": "^3.9.0",
"gulp-angular-templatecache": "^2.0.0",
"gulp-autoprefixer": "^3.0.1", "gulp-autoprefixer": "^3.0.1",
"gulp-cssnano": "^2.0.0", "gulp-cssnano": "^2.0.0",
"gulp-eslint": "^2.0.0", "gulp-eslint": "^2.0.0",

View file

@ -331,6 +331,7 @@
<script src="scripts/services/aria2RpcService.js"></script> <script src="scripts/services/aria2RpcService.js"></script>
<script src="scripts/services/aria2TaskService.js"></script> <script src="scripts/services/aria2TaskService.js"></script>
<script src="scripts/services/aria2SettingService.js"></script> <script src="scripts/services/aria2SettingService.js"></script>
<script src="scripts/views/templates.js"></script>
<!-- endbuild --> <!-- endbuild -->
</body> </body>
</html> </html>