|
|
@ -4,28 +4,29 @@ var pj = require('./package.json'); |
|
|
|
var $ = require('gulp-load-plugins')(); |
|
|
|
var $ = require('gulp-load-plugins')(); |
|
|
|
var concat = require('gulp-concat'); |
|
|
|
var concat = require('gulp-concat'); |
|
|
|
|
|
|
|
|
|
|
|
gulp.task('usemin', ['templates'], function() { |
|
|
|
|
|
|
|
return gulp.src('app/index.html') |
|
|
|
|
|
|
|
.pipe($.usemin({ |
|
|
|
|
|
|
|
html: [$.minifyHtml({empty: true})], |
|
|
|
|
|
|
|
js: ['concat', $.rev()], |
|
|
|
|
|
|
|
css: [$.minifyCss(), 'concat'] |
|
|
|
|
|
|
|
})) |
|
|
|
|
|
|
|
.pipe(gulp.dest('dist')); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 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.
|
|
|
|
gulp.task('templates', function() { |
|
|
|
gulp.task('templates', function() { |
|
|
|
return gulp.src('app/partials/*.html') |
|
|
|
return gulp.src('app/partials/*.html') |
|
|
|
.pipe($.angularTemplatecache('partials.js', { |
|
|
|
.pipe($.angularTemplatecache('templates.js', { |
|
|
|
root: 'partials', |
|
|
|
root: 'partials', |
|
|
|
module: 'partials', |
|
|
|
module: 'myApp.templates', |
|
|
|
standalone: true |
|
|
|
standalone: true |
|
|
|
})) |
|
|
|
})) |
|
|
|
.pipe(gulp.dest('app/js')); |
|
|
|
.pipe(gulp.dest('app/js')); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
gulp.task('usemin', ['templates', 'enable-production'], function() { |
|
|
|
|
|
|
|
return gulp.src('app/index.html') |
|
|
|
|
|
|
|
.pipe($.usemin({ |
|
|
|
|
|
|
|
html: [$.minifyHtml({empty: true})], |
|
|
|
|
|
|
|
js: ['concat', $.rev()], |
|
|
|
|
|
|
|
css: [$.minifyCss(), 'concat'] |
|
|
|
|
|
|
|
})) |
|
|
|
|
|
|
|
.pipe(gulp.dest('dist')); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
gulp.task('copy', function() { |
|
|
|
gulp.task('copy', function() { |
|
|
|
return es.concat( |
|
|
|
return es.concat( |
|
|
|
gulp.src(['app/favicon.ico', 'app/favicon_unread.ico', 'app/manifest.webapp', 'app/manifest.json', 'app/**/*worker.js']) |
|
|
|
gulp.src(['app/favicon.ico', 'app/favicon_unread.ico', 'app/manifest.webapp', 'app/manifest.json', 'app/**/*worker.js']) |
|
|
@ -46,13 +47,13 @@ gulp.task('copy', function() { |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
gulp.task('compress-dist', ['add-csp'], function() { |
|
|
|
gulp.task('compress-dist', ['add-csp'], function() { |
|
|
|
return es.concat( |
|
|
|
return gulp.src('dist/**/*') |
|
|
|
gulp.src('dist/*') |
|
|
|
|
|
|
|
.pipe($.zip('webogram_v' + pj.version + '.zip')) |
|
|
|
.pipe($.zip('webogram_v' + pj.version + '.zip')) |
|
|
|
.pipe(gulp.dest('package')), |
|
|
|
.pipe(gulp.dest('releases')); |
|
|
|
gulp.src('package/*.zip') |
|
|
|
}); |
|
|
|
.pipe(gulp.dest('.')) |
|
|
|
|
|
|
|
); |
|
|
|
gulp.task('cleanup-dist', ['compress-dist'], function() { |
|
|
|
|
|
|
|
return gulp.src(['releases/**/*', '!releases/*.zip']).pipe($.clean()); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
gulp.task('add-csp', ['build'], function() { |
|
|
|
gulp.task('add-csp', ['build'], function() { |
|
|
@ -74,22 +75,48 @@ gulp.task('update-version-settings', function() { |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
gulp.task('update-version-comments', function() { |
|
|
|
gulp.task('update-version-comments', function() { |
|
|
|
return gulp.src('app/**/*') |
|
|
|
return gulp.src('app/**/*.js') |
|
|
|
.pipe($.grepStream('Webogram v')) |
|
|
|
|
|
|
|
.pipe($.replace(/Webogram v[0-9.]*/, 'Webogram v' + pj.version)) |
|
|
|
.pipe($.replace(/Webogram v[0-9.]*/, 'Webogram v' + pj.version)) |
|
|
|
.pipe(gulp.dest('app')); |
|
|
|
.pipe(gulp.dest('app')); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
gulp.task('enable-production', function() { |
|
|
|
|
|
|
|
return es.concat( |
|
|
|
|
|
|
|
gulp.src('app/**/*.html') |
|
|
|
|
|
|
|
.pipe($.replace(/PRODUCTION_ONLY_BEGIN/g, 'PRODUCTION_ONLY_BEGIN-->')) |
|
|
|
|
|
|
|
.pipe($.replace(/PRODUCTION_ONLY_END/, '<!--PRODUCTION_ONLY_END')) |
|
|
|
|
|
|
|
.pipe(gulp.dest('app')), |
|
|
|
|
|
|
|
gulp.src('app/**/*.js') |
|
|
|
|
|
|
|
.pipe($.replace(/PRODUCTION_ONLY_BEGIN(\*\/)?/g, 'PRODUCTION_ONLY_BEGIN*/')) |
|
|
|
|
|
|
|
.pipe($.replace(/(\/\*)?PRODUCTION_ONLY_END/g, '/*PRODUCTION_ONLY_END')) |
|
|
|
|
|
|
|
.pipe(gulp.dest('app')) |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
gulp.task('disable-production', function() { |
|
|
|
|
|
|
|
return es.concat( |
|
|
|
|
|
|
|
gulp.src('app/index.html') |
|
|
|
|
|
|
|
.pipe($.replace(/PRODUCTION_ONLY_BEGIN-->/g, 'PRODUCTION_ONLY_BEGIN')) |
|
|
|
|
|
|
|
.pipe($.replace(/<!--PRODUCTION_ONLY_END/g, 'PRODUCTION_ONLY_END')) |
|
|
|
|
|
|
|
.pipe(gulp.dest('app')), |
|
|
|
|
|
|
|
gulp.src('app/**/*.js') |
|
|
|
|
|
|
|
.pipe($.replace(/PRODUCTION_ONLY_BEGIN(\*\/)?/g, 'PRODUCTION_ONLY_BEGIN')) |
|
|
|
|
|
|
|
.pipe($.replace(/(\/\*)?PRODUCTION_ONLY_END/g, 'PRODUCTION_ONLY_END')) |
|
|
|
|
|
|
|
.pipe(gulp.dest('app')) |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
gulp.task('clean', function() { |
|
|
|
gulp.task('clean', function() { |
|
|
|
return gulp.src('dist').pipe($.clean()); |
|
|
|
return gulp.src(['dist/*', '!dist/.git']).pipe($.clean()); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
gulp.task('bump', ['update-version-manifests', 'update-version-settings', 'update-version-comments']); |
|
|
|
gulp.task('bump', ['update-version-manifests', 'update-version-settings', 'update-version-comments']); |
|
|
|
gulp.task('build', ['templates', 'usemin', 'copy']); |
|
|
|
gulp.task('build', ['templates', 'usemin', 'copy'], function () { |
|
|
|
gulp.task('package', ['compress-dist'], function() { |
|
|
|
gulp.start('disable-production'); |
|
|
|
gulp.src('package').pipe($.clean()); |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
gulp.task('package', ['cleanup-dist']); |
|
|
|
|
|
|
|
|
|
|
|
gulp.task('default', ['clean'], function() { |
|
|
|
gulp.task('default', ['clean'], function() { |
|
|
|
gulp.start('build'); |
|
|
|
gulp.start('build'); |
|
|
|