Skip to content

Instantly share code, notes, and snippets.

@TylerJPresley
Created January 31, 2018 16:24
Show Gist options
  • Save TylerJPresley/d045a640e45e6dd6c0fea9908d851ebf to your computer and use it in GitHub Desktop.
Save TylerJPresley/d045a640e45e6dd6c0fea9908d851ebf to your computer and use it in GitHub Desktop.
Release task for Aurelia projects
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