Skip to content

Commit 9e1514e

Browse files
committed
Merge pull request nervgh#532 from andrei-cacio/feature/dist-contains-both-versions
Updated the gulp /build task to export both uglified and normal version
2 parents 888127c + a0a8873 commit 9e1514e

File tree

2 files changed

+40
-17
lines changed

2 files changed

+40
-17
lines changed

gulpfile.js

Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
1-
2-
31
var pkg = require('./package.json');
42
// https://github.com/gulpjs/gulp/blob/master/docs/README.md
53
var gulp = require('gulp');
64
// http://webpack.github.io/docs/
75
var webpack = require('webpack');
86
// https://github.com/shama/webpack-stream
97
var webpackStream = require('webpack-stream');
10-
8+
// https://github.com/dominictarr/event-stream
9+
var es = require('event-stream');
10+
// https://github.com/justmoon/node-extend
11+
var extend = require('extend');
1112

1213
gulp.task(
1314
pkg.name + '/build',
1415
function() {
15-
return gulp
16-
.src('./src/index.js')
17-
.pipe(webpackStream({
16+
var normalWebpackStream = {
1817
module: {
1918
loaders: [
2019
// https://github.com/babel/babel-loader
@@ -26,12 +25,7 @@ gulp.task(
2625
]
2726
},
2827
plugins: [
29-
// http://webpack.github.io/docs/list-of-plugins.html#uglifyjsplugin
30-
new webpack.optimize.UglifyJsPlugin({
31-
compress: {
32-
warnings: false
33-
}
34-
}),
28+
3529
// http://webpack.github.io/docs/list-of-plugins.html#bannerplugin
3630
new webpack.BannerPlugin(
3731
'/*\n' +
@@ -48,10 +42,37 @@ gulp.task(
4842
output: {
4943
library: pkg.name,
5044
libraryTarget: 'umd',
51-
filename: pkg.name + '.min.js'
45+
filename: pkg.name + '.js'
5246
}
53-
}))
54-
.pipe(gulp.dest('./dist'));
47+
},
48+
normalStream =
49+
gulp
50+
.src('./src/index.js')
51+
.pipe(webpackStream(normalWebpackStream))
52+
.pipe(gulp.dest('./dist'));
53+
54+
/**
55+
* Deep copy the normalWebpackStream to customize it for the uglify stream
56+
*/
57+
var ulgifyWebpackStream = extend(true, {}, normalWebpackStream);
58+
59+
ulgifyWebpackStream.plugins.unshift(
60+
// http://webpack.github.io/docs/list-of-plugins.html#uglifyjsplugin
61+
new webpack.optimize.UglifyJsPlugin({
62+
compress: {
63+
warnings: false
64+
}
65+
}));
66+
67+
ulgifyWebpackStream.output.filename = pkg.name + '.min.js';
68+
69+
var uglifyStream =
70+
gulp
71+
.src('./src/index.js')
72+
.pipe(webpackStream(ulgifyWebpackStream))
73+
.pipe(gulp.dest('./dist'));
74+
75+
return es.concat(normalStream, uglifyStream);
5576
}
5677
);
5778

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@
1111
"devDependencies": {
1212
"babel": "^4.7.16",
1313
"babel-loader": "^4.0.0",
14-
"json-loader": "^0.5.1",
15-
"html-loader": "^0.2.3",
14+
"event-stream": "^3.3.2",
15+
"extend": "^3.0.0",
1616
"gulp": "^3.9.0",
17+
"html-loader": "^0.2.3",
18+
"json-loader": "^0.5.1",
1719
"webpack": "^1.10.1",
1820
"webpack-stream": "^2.0.0"
1921
}

0 commit comments

Comments
 (0)