diff --git a/gulpfile.js b/gulpfile.js index 195e3f3ca..f61e15b69 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -23,6 +23,8 @@ var sass = require('gulp-sass') var autoprefixer = require('gulp-autoprefixer') var gulpStylelint = require('gulp-stylelint') var stylefmt = require('gulp-stylefmt') +var uglify = require('gulp-uglify') +var babel = require('gulp-babel') var disableDebugTools = gutil.env.disableDebugTools @@ -375,6 +377,11 @@ function bundleTask(opts) { // sourcemaps // loads map from browserify file .pipe(gulpif(debug, sourcemaps.init({ loadMaps: true }))) + // Minification + .pipe(babel({ + presets: ['env'] + })) + .pipe(uglify()) // writes .map file .pipe(gulpif(debug, sourcemaps.write('./'))) // write completed bundles diff --git a/mascara/server/index.js b/mascara/server/index.js index 83f84f6d1..6fb1287cc 100644 --- a/mascara/server/index.js +++ b/mascara/server/index.js @@ -2,6 +2,7 @@ const path = require('path') const express = require('express') const createBundle = require('./util').createBundle const serveBundle = require('./util').serveBundle +const compression = require('compression') module.exports = createMetamascaraServer @@ -16,6 +17,8 @@ function createMetamascaraServer () { // serve bundles const server = express() + server.use(compression()) + // ui window serveBundle(server, '/ui.js', uiBundle) server.use(express.static(path.join(__dirname, '/../ui/'), { setHeaders: (res) => res.set('X-Frame-Options', 'DENY') })) diff --git a/mascara/server/util.js b/mascara/server/util.js index af2daddb9..f9692afb6 100644 --- a/mascara/server/util.js +++ b/mascara/server/util.js @@ -23,7 +23,9 @@ function createBundle (entryPoint) { cache: {}, packageCache: {}, plugin: [watchify], - }).transform('babelify') + }) + .transform('babelify') + .transform('uglifyify', { global: true }) bundler.on('update', bundle) bundle() diff --git a/package.json b/package.json index 4469263cc..9bbdacea2 100644 --- a/package.json +++ b/package.json @@ -199,6 +199,7 @@ "eth-json-rpc-middleware": "^1.2.7", "fs-promise": "^2.0.3", "gulp": "github:gulpjs/gulp#4.0", + "gulp-babel": "^7.0.0", "gulp-if": "^2.0.1", "gulp-json-editor": "^2.2.1", "gulp-livereload": "^3.8.1", @@ -206,6 +207,7 @@ "gulp-sourcemaps": "^2.6.0", "gulp-stylefmt": "^1.1.0", "gulp-stylelint": "^4.0.0", + "gulp-uglify": "^3.0.0", "gulp-util": "^3.0.7", "gulp-watch": "^4.3.5", "gulp-zip": "^4.0.0",