|
|
@ -7,6 +7,8 @@ var http = require('http') |
|
|
|
var st = require('st') |
|
|
|
var st = require('st') |
|
|
|
var del = require('del') |
|
|
|
var del = require('del') |
|
|
|
var runSequence = require('run-sequence') |
|
|
|
var runSequence = require('run-sequence') |
|
|
|
|
|
|
|
var swPrecache = require('sw-precache') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// The generated file is being created at src
|
|
|
|
// The generated file is being created at src
|
|
|
|
// so it can be fetched by usemin.
|
|
|
|
// so it can be fetched by usemin.
|
|
|
@ -19,6 +21,19 @@ gulp.task('templates', function () { |
|
|
|
})) |
|
|
|
})) |
|
|
|
.pipe(gulp.dest('app/js')) |
|
|
|
.pipe(gulp.dest('app/js')) |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
gulp.task('clean-templates', function () { |
|
|
|
|
|
|
|
return del(['app/js/templates.js']) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
gulp.task('usemin-index', function () { |
|
|
|
|
|
|
|
return gulp.src('app/index.html') |
|
|
|
|
|
|
|
.pipe($.usemin({ |
|
|
|
|
|
|
|
html: [$.minifyHtml({empty: true})], |
|
|
|
|
|
|
|
js: ['concat', $.ngAnnotate()/*, $.uglify({outSourceMap: false})*/], |
|
|
|
|
|
|
|
css: ['concat', $.minifyCss({compatibility: true, keepBreaks: true})] |
|
|
|
|
|
|
|
})) |
|
|
|
|
|
|
|
.pipe(gulp.dest('dist')) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
gulp.task('usemin-badbrowser', function() { |
|
|
|
gulp.task('usemin-badbrowser', function() { |
|
|
|
return gulp.src('app/badbrowser.html') |
|
|
|
return gulp.src('app/badbrowser.html') |
|
|
@ -29,16 +44,6 @@ gulp.task('usemin-badbrowser', function() { |
|
|
|
.pipe(gulp.dest('dist')); |
|
|
|
.pipe(gulp.dest('dist')); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
gulp.task('usemin', function () { |
|
|
|
|
|
|
|
return gulp.src('app/index.html') |
|
|
|
|
|
|
|
.pipe($.usemin({ |
|
|
|
|
|
|
|
html: [$.minifyHtml({empty: true})], |
|
|
|
|
|
|
|
js: ['concat', $.ngAnnotate(), $.uglify({outSourceMap: false})], |
|
|
|
|
|
|
|
css: ['concat', $.minifyCss({compatibility: true, keepBreaks: true})] |
|
|
|
|
|
|
|
})) |
|
|
|
|
|
|
|
.pipe(gulp.dest('dist')) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ulimit -n 10240 on OS X
|
|
|
|
// ulimit -n 10240 on OS X
|
|
|
|
gulp.task('imagemin', function () { |
|
|
|
gulp.task('imagemin', function () { |
|
|
|
return gulp.src(['app/img/**/*', '!app/img/screenshot*', '!app/img/*.wav']) |
|
|
|
return gulp.src(['app/img/**/*', '!app/img/screenshot*', '!app/img/*.wav']) |
|
|
@ -172,7 +177,8 @@ var fileGlobs = [ |
|
|
|
'!dist/*.html', |
|
|
|
'!dist/*.html', |
|
|
|
'!dist/fonts/*', |
|
|
|
'!dist/fonts/*', |
|
|
|
'!dist/img/icons/icon*.png', |
|
|
|
'!dist/img/icons/icon*.png', |
|
|
|
'!dist/js/background.js' |
|
|
|
'!dist/js/background.js', |
|
|
|
|
|
|
|
'!dist/css/badbrowser.css' |
|
|
|
] |
|
|
|
] |
|
|
|
|
|
|
|
|
|
|
|
function writeServiceWorkerFile (rootDir, handleFetch, callback) { |
|
|
|
function writeServiceWorkerFile (rootDir, handleFetch, callback) { |
|
|
@ -181,7 +187,8 @@ function writeServiceWorkerFile (rootDir, handleFetch, callback) { |
|
|
|
handleFetch: handleFetch, |
|
|
|
handleFetch: handleFetch, |
|
|
|
logger: $.util.log, |
|
|
|
logger: $.util.log, |
|
|
|
staticFileGlobs: fileGlobs, |
|
|
|
staticFileGlobs: fileGlobs, |
|
|
|
stripPrefix: rootDir + '/', |
|
|
|
stripPrefix: './' + rootDir + '/', |
|
|
|
|
|
|
|
importScripts: ['js/lib/push_worker.js'], |
|
|
|
verbose: true |
|
|
|
verbose: true |
|
|
|
} |
|
|
|
} |
|
|
|
swPrecache.write(path.join(rootDir, 'service_worker.js'), config, callback) |
|
|
|
swPrecache.write(path.join(rootDir, 'service_worker.js'), config, callback) |
|
|
@ -272,16 +279,17 @@ gulp.task('build', ['clean'], function (callback) { |
|
|
|
runSequence( |
|
|
|
runSequence( |
|
|
|
['less', 'templates'], |
|
|
|
['less', 'templates'], |
|
|
|
'enable-production', |
|
|
|
'enable-production', |
|
|
|
'usemin', |
|
|
|
'usemin-index', |
|
|
|
'usemin-badbrowser', |
|
|
|
'usemin-badbrowser', |
|
|
|
['copy', 'copy-locales', 'copy-images', 'disable-production'], |
|
|
|
['copy', 'copy-locales', 'copy-images', 'disable-production'], |
|
|
|
|
|
|
|
'clean-templates', |
|
|
|
callback |
|
|
|
callback |
|
|
|
) |
|
|
|
) |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
gulp.task('package', ['cleanup-dist']) |
|
|
|
gulp.task('package', ['cleanup-dist']) |
|
|
|
|
|
|
|
|
|
|
|
gulp.task('offline', ['add-appcache-manifest', 'generate-service-worker']) |
|
|
|
gulp.task('publish', ['add-appcache-manifest', 'generate-service-worker']) |
|
|
|
|
|
|
|
|
|
|
|
gulp.task('deploy', function () { |
|
|
|
gulp.task('deploy', function () { |
|
|
|
return gulp.src('./dist/**/*') |
|
|
|
return gulp.src('./dist/**/*') |
|
|
|