davinkevin / angularjs-jspm-seed

A example seed for AngularJS and JSPM project
Apache License 2.0
14 stars 5 forks source link

feat(compress): add gzip compression #6

Closed davinkevin closed 8 years ago

davinkevin commented 8 years ago

Using https://www.npmjs.com/package/gulp-gzip

import gzip from 'gulp-gzip';

gulp.task('build-js', () => {
  return gulp.src(`${paths.releaseDir}/${paths.app.name}.js`)
    .pipe(sourcemaps.init({loadMaps: true}))
    .pipe(ngAnnotate())
    .pipe(uglify({ compress : false }))
    .pipe(rename({suffix : '.min'}))
    .pipe(sourcemaps.write('.'))
    .pipe(gulp.dest(paths.releaseDir))
    .pipe(gzip())
    .pipe(gulp.dest(paths.releaseDir))
});

And modify index.html to load gz instead of js

davinkevin commented 8 years ago

We should use for "serve-prod" a system like https://www.npmjs.com/package/connect-gzip-static to serve gz if present and compatible and js / css in other case. This require browser-sync to serve file in prod mode.

After inspection, CSS gzip is divided by 6 and JS by 3

aubm commented 8 years ago

Closing that one as serve-prod should not be used in actual production anyway.