Skip to content

Commit cf5b4be

Browse files
committed
Merge pull request DuendeArchive#33 from maxmantz/dev
Multiple build targets with gulp & webpack
2 parents 5a90b89 + be337d5 commit cf5b4be

File tree

9 files changed

+12605
-184
lines changed

9 files changed

+12605
-184
lines changed

dist/oidc-client.js

Lines changed: 6146 additions & 34 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/oidc-client.min.js

Lines changed: 72 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gulpfile.js

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
var gulp = require('gulp');
2+
var webpackStream = require('webpack-stream');
3+
var webpack = require('webpack');
4+
var createWebpackConfig = require('./webpack.base');
5+
6+
// entry points for both configs
7+
var npmEntry = './index.js';
8+
var classicEntry = ['babel-polyfill', npmEntry];
9+
10+
// uglify plugin for minification
11+
var uglifyPlugins = [
12+
new webpack.optimize.UglifyJsPlugin({
13+
compress: {
14+
warnings: false,
15+
screw_ie8: true,
16+
},
17+
})
18+
];
19+
20+
// npm compliant build with source-maps
21+
gulp.task('build-lib-sourcemap', function() {
22+
// run webpack
23+
gulp.src('index.js').pipe(webpackStream(createWebpackConfig({
24+
entry: npmEntry,
25+
output: {
26+
filename: 'oidc-client.js',
27+
libraryTarget: 'umd'
28+
},
29+
plugins: [],
30+
devtool: 'inline-source-map'
31+
})))
32+
.pipe(gulp.dest('lib/'));
33+
});
34+
35+
// npm compliant build without source-maps & minified
36+
gulp.task('build-lib-min', function() {
37+
// run webpack
38+
gulp.src('index.js').pipe(webpackStream(createWebpackConfig({
39+
entry: npmEntry,
40+
output: {
41+
filename: 'oidc-client.min.js',
42+
libraryTarget: 'umd',
43+
},
44+
plugins: uglifyPlugins,
45+
devtool: null
46+
})))
47+
.pipe(gulp.dest('lib/'));
48+
});
49+
50+
// classic build with sourcemaps
51+
gulp.task('build-dist-sourcemap', function() {
52+
// run webpack
53+
gulp.src('index.js').pipe(webpackStream(createWebpackConfig({
54+
entry: classicEntry,
55+
output: {
56+
filename: 'oidc-client.js',
57+
libraryTarget: 'var',
58+
library: 'Oidc'
59+
},
60+
plugins: [
61+
],
62+
devtool: 'inline-source-map'
63+
})))
64+
.pipe(gulp.dest('dist/'));
65+
});
66+
67+
// classic build without sourcemaps & minified
68+
gulp.task('build-dist-min', function() {
69+
// run webpack
70+
gulp.src('index.js').pipe(webpackStream(createWebpackConfig({
71+
entry: classicEntry,
72+
output: {
73+
filename: 'oidc-client.min.js',
74+
libraryTarget: 'var',
75+
library: 'Oidc'
76+
},
77+
plugins: uglifyPlugins,
78+
devtool: null
79+
})))
80+
.pipe(gulp.dest('dist/'));
81+
});
82+
83+
// putting it all together
84+
gulp.task('build', ['build-lib-sourcemap', 'build-lib-min', 'build-dist-sourcemap', 'build-dist-min']);

lib/oidc-client.js

Lines changed: 6157 additions & 31 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/oidc-client.min.js

Lines changed: 72 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 49 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,53 @@
11
{
2-
"name": "oidc-client",
3-
"version": "1.0.0-beta.7",
4-
"description": "OpenID Connect (OIDC) & OAuth2 client library",
5-
"main": "lib/oidc-client.js",
6-
"scripts": {
7-
"build:lib": "webpack -p --config webpack.lib.js",
8-
"build:dist": "webpack -p --config webpack.dist.js",
9-
"prebuild": "npm run build:lib",
10-
"build": "npm run build:dist",
11-
"start": "node sample/server.js",
12-
"test": "mocha --compilers js:babel-register test/unit/*.spec.js"
2+
"name": "oidc-client",
3+
"version": "1.0.0-beta.7",
4+
"description": "OpenID Connect (OIDC) & OAuth2 client library",
5+
"main": "lib/oidc-client.min.js",
6+
"scripts": {
7+
"prepublish": "npm run build",
8+
"build": "gulp build",
9+
"start": "node sample/server.js",
10+
"test": "mocha --compilers js:babel-register test/unit/*.spec.js"
11+
},
12+
"repository": {
13+
"type": "git",
14+
"url": "https://github.com/IdentityModel/oidc-client-js.git"
15+
},
16+
"author": "Brock Allen & Dominick Baier",
17+
"contributors": [
18+
{
19+
"name": "Brock Allen",
20+
"email": "brockallen@gmail.com"
1321
},
14-
"repository": {
15-
"type": "git",
16-
"url": "https://github.com/IdentityModel/oidc-client-js.git"
17-
},
18-
"author": "Brock Allen & Dominick Baier",
19-
"contributors": [
20-
{
21-
"name": "Brock Allen",
22-
"email": "brockallen@gmail.com"
23-
},
24-
{
25-
"name": "Dominick Baier",
26-
"email": "dbaier@leastprivilege.com"
27-
}
28-
],
29-
"license": "Apache-2.0",
30-
"bugs": {
31-
"url": "https://github.com/IdentityModel/oidc-client-js/issues"
32-
},
33-
"homepage": "https://github.com/IdentityModel/oidc-client-js",
34-
"devDependencies": {
35-
"babel-core": "^6.7.2",
36-
"babel-plugin-add-module-exports": "^0.1.2",
37-
"babel-plugin-transform-es2015-classes": "^6.7.7",
38-
"babel-preset-es2015": "^6.6.0",
39-
"babel-register": "^6.7.2",
40-
"chai": "^3.5.0",
41-
"express": "^4.13.4",
42-
"mocha": "^2.4.5",
43-
"open": "0.0.5",
44-
"webpack": "^1.12.14",
45-
"babel-loader": "^6.2.4"
46-
},
47-
"dependencies": {
48-
"jsrsasign": "^5.0.7"
49-
},
50-
"peerDependencies": {
51-
"babel-polyfill": ">=6.7.4"
22+
{
23+
"name": "Dominick Baier",
24+
"email": "dbaier@leastprivilege.com"
5225
}
26+
],
27+
"license": "Apache-2.0",
28+
"bugs": {
29+
"url": "https://github.com/IdentityModel/oidc-client-js/issues"
30+
},
31+
"homepage": "https://github.com/IdentityModel/oidc-client-js",
32+
"devDependencies": {
33+
"babel-core": "^6.7.2",
34+
"babel-loader": "^6.2.4",
35+
"babel-plugin-add-module-exports": "^0.1.2",
36+
"babel-plugin-transform-es2015-classes": "^6.7.7",
37+
"babel-preset-es2015": "^6.6.0",
38+
"babel-register": "^6.7.2",
39+
"chai": "^3.5.0",
40+
"express": "^4.13.4",
41+
"gulp": "^3.9.1",
42+
"mocha": "^2.4.5",
43+
"open": "0.0.5",
44+
"webpack": "^1.12.14",
45+
"webpack-stream": "^3.2.0"
46+
},
47+
"dependencies": {
48+
"jsrsasign": "^5.0.7"
49+
},
50+
"peerDependencies": {
51+
"babel-polyfill": ">=6.7.4"
52+
}
5353
}

webpack.base.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// create a webpack configuration with all common parts included here
2+
var createWebpackConfig = function(options) {
3+
return {
4+
entry: options.entry,
5+
output: options.output,
6+
plugins: options.plugins,
7+
node: {
8+
fs: 'empty' // Because of jsrsasign usage of fs
9+
},
10+
module: {
11+
loaders: [
12+
{
13+
test: /.js$/,
14+
loaders: ['babel'],
15+
exclude: /node_modules/,
16+
include: __dirname
17+
}
18+
]
19+
},
20+
// this is for the sourcemaps
21+
devtool: options.devtool
22+
};
23+
};
24+
25+
module.exports = createWebpackConfig;

webpack.dist.js

Lines changed: 0 additions & 36 deletions
This file was deleted.

webpack.lib.js

Lines changed: 0 additions & 34 deletions
This file was deleted.

0 commit comments

Comments
 (0)