Created
January 31, 2018 16:24
-
-
Save TylerJPresley/d045a640e45e6dd6c0fea9908d851ebf to your computer and use it in GitHub Desktop.
Release task for Aurelia projects
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as gulp from 'gulp'; | |
import * as htmlMin from 'gulp-htmlmin'; | |
import * as gzip from 'gulp-gzip'; | |
import * as del from 'del'; | |
import * as jsonMinify from 'gulp-json-minify'; | |
import * as vinylPaths from 'vinyl-paths'; | |
import * as stripDebug from 'gulp-strip-debug'; | |
import * as stripComments from 'gulp-strip-comments'; | |
const copyFnArray = []; | |
const copyList = [ | |
{ src: 'app/*-*.js', dest: './export/app' }, | |
{ src: 'assets/**/*', dest: './export/assets' }, | |
{ src: 'manifest.json', dest: './export' }, | |
{ src: 'index.html', dest: './export' } | |
]; | |
for (let i = 0, j = copyList.length; i < j; i++) { | |
copyFnArray.push(() => { | |
console.log(`copying item ${i + 1}`, copyList[i]); | |
return gulp.src(copyList[i].src) | |
.pipe(gulp.dest(copyList[i].dest)); | |
}); | |
} | |
function cleanExport() { | |
return gulp.src('./export') | |
.pipe(vinylPaths(del)); | |
} | |
function cleanApp() { | |
return gulp.src('./app') | |
.pipe(vinylPaths(del)); | |
} | |
function prepIndex() { | |
return gulp.src('./export/index.html') | |
.pipe(htmlMin({ collapseWhitespace: true })) | |
.pipe(gulp.dest('./export')) | |
.pipe(gzip()) | |
.pipe(gulp.dest('./export')); | |
} | |
function prepJs() { | |
return gulp.src('./export/**/*.js') | |
.pipe(stripDebug()) | |
.pipe(stripComments({ safe: true })) | |
.pipe(gulp.dest('./export')) | |
.pipe(gzip()) | |
.pipe(gulp.dest('./export')); | |
} | |
function prepJson() { | |
return gulp.src('./export/**/*.json') | |
.pipe(jsonMinify()) | |
.pipe(gulp.dest('./export')); | |
} | |
const release = gulp['series']( | |
cleanExport, | |
copyFnArray, | |
prepJs, | |
prepJson, | |
prepIndex, | |
cleanApp | |
); | |
export default release; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment