Skip to content
This repository has been archived by the owner on Aug 31, 2021. It is now read-only.

Use uglify instead of minifify and fix up sourcemap generation #192

Merged
merged 1 commit into from
Sep 23, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 21 additions & 17 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,44 +15,48 @@
*/
'use strict';

var path = require('path');
var browserify = require('browserify');
var buffer = require('vinyl-buffer');
var eslint = require('gulp-eslint');
var ghPages = require('gulp-gh-pages');
var gulp = require('gulp');
var header = require('gulp-header');
var path = require('path');
var source = require('vinyl-source-stream');
var sourcemaps = require('gulp-sourcemaps');
var temp = require('temp').track();
var testServer = require('./test/server/index.js');
var uglify = require('gulp-uglify');

var buildSources = ['lib/**/*.js'];
var lintSources = buildSources.concat([
'gulpfile.js',
'recipes/**/*.js',
'test/**/*.js']);

gulp.task('test:manual', function() {
gulp.task('test:manual', ['build'], function() {
testServer.startServer(path.join(__dirname), 8888)
.then(portNumber => {
console.log(`Tests are available at http://localhost:${portNumber}`);
});
.then(portNumber => {
console.log(`Tests are available at http://localhost:${portNumber}`);
});
});

gulp.task('build', function() {
var bundler = browserify({
entries: ['./lib/sw-toolbox.js'],
standalone: 'toolbox',
debug: true
});

bundler.plugin('browserify-header');
bundler.plugin('minifyify', {
map: './build/sw-toolbox.map.json',
output: './build/sw-toolbox.map.json'
});
var bundler = browserify({
entries: ['./lib/sw-toolbox.js'],
standalone: 'toolbox',
debug: true
});

gulp.task('build', function() {
var license = '/* \n Copyright 2016 Google Inc. All Rights Reserved.\n\n Licensed under the Apache License, Version 2.0 (the "License");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an "AS IS" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n*/';
return bundler
.bundle()
.pipe(source('sw-toolbox.js'))
.pipe(buffer())
.pipe(sourcemaps.init({loadMaps: true}))
.pipe(uglify())
.pipe(header(license))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('./build/'));
});

Expand Down
8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
"path-to-regexp": "^1.0.1"
},
"devDependencies": {
"browserify": "^12.0.1",
"browserify-header": "^0.9.2",
"browserify": "^13.1.0",
"chai": "^3.4.1",
"chromedriver": "^2.24.1",
"cookie-parser": "^1.4.1",
Expand All @@ -30,9 +29,11 @@
"gulp": "^3.9.0",
"gulp-eslint": "^1.1.1",
"gulp-gh-pages": "^0.5.4",
"gulp-header": "^1.8.8",
"gulp-sourcemaps": "^1.6.0",
"gulp-uglify": "^2.0.0",
"jsdoc": "^3.4.0",
"jshint-stylish": "^2.1.0",
"minifyify": "^7.1.0",
"mocha": "^2.3.4",
"npm-publish-scripts": "^2.0.7",
"operadriver": "^0.2.2",
Expand All @@ -41,6 +42,7 @@
"selenium-webdriver": "^3.0.0-beta-2",
"sw-testing-helpers": "0.1.4",
"temp": "^0.8.3",
"vinyl-buffer": "^1.0.0",
"vinyl-source-stream": "^1.1.0",
"which": "^1.2.4"
},
Expand Down