Skip to content

Commit

Permalink
Build: upgrade build environment (#70)
Browse files Browse the repository at this point in the history
  • Loading branch information
linuxwolf committed Aug 23, 2016
1 parent 0c04523 commit 8f62598
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 38 deletions.
62 changes: 30 additions & 32 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ var ARGV = require("yargs").
help("help").
argv;

var browserify = require("browserify"),
var webpack = require("webpack-stream"),
clone = require("lodash.clone"),
gulp = require("gulp"),
karma = require("karma"),
Expand Down Expand Up @@ -119,46 +119,37 @@ gulp.task("test:nodejs", function(cb) {
});

// ### BROWSER TASKS ###
function doBrowserify(suffix, steps) {
var source = require("vinyl-source-stream"),
buffer = require("vinyl-buffer"),
sourcemaps = require("gulp-sourcemaps");

function doBrowserify(suffix, plugins) {
var pkg = require("./package.json");

suffix = suffix || ".js";
steps = steps || [];

var stream = browserify({
entries: require("path").resolve(pkg.main),
standalone: "jose"
}).bundle().
pipe(source(pkg.name + suffix)).
pipe(buffer());

steps.forEach(function(s) {
stream = stream.pipe(s);
});

return stream.pipe(sourcemaps.init({ loadMaps: true })).
pipe(sourcemaps.write("./")).
pipe(gulp.dest("./dist"));
plugins = plugins || [];

return gulp.src(require("path").resolve(pkg.main)).
pipe(webpack({
output: {
filename: pkg.name + suffix
},
plugins: plugins,
devtool: "source-map"
})).
pipe(gulp.dest("./dist"));
}

gulp.task("bundle", function() {
return doBrowserify();
});

gulp.task("minify", function() {
var uglify = require("gulp-uglify");

return doBrowserify(".min.js", [
uglify()
new webpack.webpack.optimize.UglifyJsPlugin({
minimize: true
})
]);
});

var KARMA_CONFIG = {
frameworks: ["mocha", "browserify"],
frameworks: ["mocha"],
basePath: ".",
browserDisconnectTolerance: 1,
browserDisconnectTimeout: 600000,
Expand All @@ -167,12 +158,19 @@ var KARMA_CONFIG = {
mocha: MOCHA_CONFIG
},
preprocessors: {
"test/**/*-test.js": ["browserify"]
"test/**/*-test.js": ["webpack"]
},
reporters: ["mocha"],
browserify: {
debug: true
webpack: {
module: {
loaders: [
{
test: /\.json$/,
loader: "json"
}
]
}
},
reporters: ["mocha"],
customLaunchers: {
"SL_Chrome": {
base: "SauceLabs",
Expand Down Expand Up @@ -213,14 +211,14 @@ var KARMA_CONFIG = {
},
captureTimeout: 600000,
sauceLabs: {
testName: "node-jose",
testName: require("./package.json").name,
commandTimeout: 300
},
files: [TESTS]
};
var KARMA_BROWSERS = {
local: ["Chrome", "Firefox"],
saucelabs: ["SL_Chrome", "SL_Firefox", "SL_Safari_7", "SL_Safari_8", "SL_Safari_9", "SL_IE_10", "SL_IE_11", "SL_EDGE"]
saucelabs: ["SL_Chrome", "SL_Firefox", "SL_Safari_8", "SL_Safari_9", "SL_IE_10", "SL_IE_11", "SL_EDGE"]
};
// allow for IE on windows
if (/^win/.test(process.platform)) {
Expand Down
11 changes: 5 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
"uuid": "^2.0.1"
},
"devDependencies": {
"browserify": "^13.0.0",
"browserify-istanbul": "^2.0.0",
"chai": "^3.5.0",
"conventional-changelog": "^1.1.0",
Expand All @@ -54,12 +53,11 @@
"gulp-istanbul": "^0.10.4",
"gulp-mocha": "^2.0.0",
"gulp-rename": "^1.2.0",
"gulp-sourcemaps": "^1.3.0",
"gulp-uglify": "^1.1.0",
"istanbul": "^0.4.0",
"jose-cookbook": "git+https://github.com/ietf-jose/cookbook.git",
"karma": "^0.13.22",
"karma-browserify": "^5.0.3",
"json-loader": "^0.5.4",
"karma": "^1.2.0",
"karma-chrome-launcher": "^0.2.3",
"karma-coverage": "^0.5.3",
"karma-firefox-launcher": "^0.1.4",
Expand All @@ -68,14 +66,15 @@
"karma-mocha-reporter": "^2.0.0",
"karma-safari-launcher": "^0.1.1",
"karma-sauce-launcher": "^0.3.1",
"karma-webpack": "^1.8.0",
"lodash.bind": "^4.1.3",
"lodash.clonedeep": "^4.3.2",
"lodash.foreach": "^4.2.0",
"mocha": "^2.1.0",
"run-sequence": "^1.0.2",
"vinyl-buffer": "^1.0.0",
"vinyl-source-stream": "^1.0.0",
"watchify": "^3.7.0",
"webpack": "^1.13.2",
"webpack-stream": "^3.2.0",
"yargs": "^4.6.0"
},
"browser": {
Expand Down

0 comments on commit 8f62598

Please sign in to comment.