support html5 application cache
This commit is contained in:
parent
0623374b39
commit
9b1544880d
41
gulpfile.js
41
gulpfile.js
|
@ -41,24 +41,29 @@ gulp.task('lint', function () {
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('html', ['styles', 'scripts', 'views'], function () {
|
gulp.task('html', ['styles', 'scripts', 'views'], function () {
|
||||||
return gulp.src('src/*.html')
|
return gulp.src([
|
||||||
.pipe($.useref({searchPath: ['.tmp', 'src', '.']}))
|
'src/*.html'
|
||||||
|
]).pipe($.useref({searchPath: ['.tmp', 'src', '.']}))
|
||||||
.pipe($.if('js/*.js', $.replace(/\/\/# sourceMappingURL=.*/g, '')))
|
.pipe($.if('js/*.js', $.replace(/\/\/# sourceMappingURL=.*/g, '')))
|
||||||
.pipe($.if('css/*.css', $.replace(/\/\*# sourceMappingURL=.* \*\/$/g, '')))
|
.pipe($.if('css/*.css', $.replace(/\/\*# sourceMappingURL=.* \*\/$/g, '')))
|
||||||
.pipe($.if(['js/moment-with-locales-*.min.js', 'js/plugins.min.js', 'js/aria-ng.min.js'], $.uglify({preserveComments: 'license'})))
|
.pipe($.if(['js/moment-with-locales-*.min.js', 'js/plugins.min.js', 'js/aria-ng.min.js'], $.uglify({preserveComments: 'license'})))
|
||||||
.pipe($.if(['css/plugins.min.css', 'css/aria-ng.min.css'], $.cssnano({safe: true, autoprefixer: false})))
|
.pipe($.if(['css/plugins.min.css', 'css/aria-ng.min.css'], $.cssnano({safe: true, autoprefixer: false})))
|
||||||
|
.pipe($.if(['js/plugins.min.js', 'js/aria-ng.min.js', 'css/plugins.min.css', 'css/aria-ng.min.css'], $.rev()))
|
||||||
.pipe($.if('*.html', $.htmlmin({collapseWhitespace: true})))
|
.pipe($.if('*.html', $.htmlmin({collapseWhitespace: true})))
|
||||||
|
.pipe($.revReplace())
|
||||||
.pipe(gulp.dest('dist'));
|
.pipe(gulp.dest('dist'));
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('langs', function () {
|
gulp.task('langs', function () {
|
||||||
return gulp.src('src/langs/**/*')
|
return gulp.src([
|
||||||
.pipe(gulp.dest('dist/langs'));
|
'src/langs/**/*'
|
||||||
|
]).pipe(gulp.dest('dist/langs'));
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('images', function () {
|
gulp.task('images', function () {
|
||||||
return gulp.src('src/imgs/**/*')
|
return gulp.src([
|
||||||
.pipe(gulp.dest('dist/imgs'));
|
'src/imgs/**/*'
|
||||||
|
]).pipe(gulp.dest('dist/imgs'));
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('fonts', function () {
|
gulp.task('fonts', function () {
|
||||||
|
@ -69,6 +74,20 @@ gulp.task('fonts', function () {
|
||||||
.pipe(gulp.dest('dist/fonts'));
|
.pipe(gulp.dest('dist/fonts'));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
gulp.task('manifest', function () {
|
||||||
|
return gulp.src([
|
||||||
|
'dist/**'
|
||||||
|
], {base: 'dist/'})
|
||||||
|
.pipe($.manifest({
|
||||||
|
hash: true,
|
||||||
|
preferOnline: true,
|
||||||
|
network: ['*'],
|
||||||
|
filename: 'index.manifest',
|
||||||
|
exclude: 'index.manifest'
|
||||||
|
}))
|
||||||
|
.pipe(gulp.dest('dist'));
|
||||||
|
});
|
||||||
|
|
||||||
gulp.task('extras', function () {
|
gulp.task('extras', function () {
|
||||||
return gulp.src([
|
return gulp.src([
|
||||||
'src/*.*',
|
'src/*.*',
|
||||||
|
@ -94,7 +113,7 @@ gulp.task('serve', ['styles', 'scripts', 'fonts'], function () {
|
||||||
|
|
||||||
gulp.watch([
|
gulp.watch([
|
||||||
'src/*.html',
|
'src/*.html',
|
||||||
'src/langs/*.json',
|
'src/langs/*.txt',
|
||||||
'src/views/*.html',
|
'src/views/*.html',
|
||||||
'src/imgs/**/*',
|
'src/imgs/**/*',
|
||||||
'.tmp/fonts/**/*'
|
'.tmp/fonts/**/*'
|
||||||
|
@ -115,10 +134,14 @@ gulp.task('serve:dist', function () {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('build', ['lint', 'html', 'langs', 'images', 'fonts', 'extras'], function () {
|
gulp.task('info', function () {
|
||||||
return gulp.src('dist/**/*').pipe($.size({title: 'build', gzip: true}));
|
return gulp.src([
|
||||||
|
'dist/**/*'
|
||||||
|
]).pipe($.size({title: 'build', gzip: true}));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
gulp.task('build', $.sequence('lint', 'html', 'langs', 'images', 'fonts', 'manifest', 'extras', 'info'));
|
||||||
|
|
||||||
gulp.task('default', ['clean'], function () {
|
gulp.task('default', ['clean'], function () {
|
||||||
gulp.start('build');
|
gulp.start('build');
|
||||||
});
|
});
|
||||||
|
|
|
@ -14,8 +14,12 @@
|
||||||
"gulp-htmlmin": "^2.0.0",
|
"gulp-htmlmin": "^2.0.0",
|
||||||
"gulp-if": "^2.0.1",
|
"gulp-if": "^2.0.1",
|
||||||
"gulp-load-plugins": "^1.2.4",
|
"gulp-load-plugins": "^1.2.4",
|
||||||
|
"gulp-manifest": "^0.1.1",
|
||||||
"gulp-plumber": "^1.1.0",
|
"gulp-plumber": "^1.1.0",
|
||||||
"gulp-replace": "^0.5.4",
|
"gulp-replace": "^0.5.4",
|
||||||
|
"gulp-rev": "^7.1.0",
|
||||||
|
"gulp-rev-replace": "^0.4.3",
|
||||||
|
"gulp-sequence": "^0.4.5",
|
||||||
"gulp-size": "^2.1.0",
|
"gulp-size": "^2.1.0",
|
||||||
"gulp-sourcemaps": "^1.6.0",
|
"gulp-sourcemaps": "^1.6.0",
|
||||||
"gulp-uglify": "^1.5.4",
|
"gulp-uglify": "^1.5.4",
|
||||||
|
|
|
@ -13,6 +13,7 @@ if [ $CI == "true" ] && [ $CIRCLE_BRANCH == "master" ]; then
|
||||||
rm -rf langs;
|
rm -rf langs;
|
||||||
rm -rf imgs;
|
rm -rf imgs;
|
||||||
rm -f index.html;
|
rm -f index.html;
|
||||||
|
rm -f index.manifest;
|
||||||
rm -f README.md;
|
rm -f README.md;
|
||||||
rm -f LICENSE;
|
rm -f LICENSE;
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html ng-app="ariaNg">
|
<html ng-app="ariaNg" manifest="index.manifest">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
|
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
|
||||||
|
|
Reference in a new issue