-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathgulpfile.js
66 lines (58 loc) · 1.45 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
var gulp = require('gulp');
var webpack = require('webpack');
var gulpWebpack = require('gulp-webpack');
gulp.task('build', ['webpack', 'webpack-min']);
var FILE_NAME = 'sync-browser-mocks';
var MODULE_NAME = 'syncBrowserMocks';
var WEBPACK_CONFIG = {
module: {
loaders: [
{
test: /\.js$/,
exclude: /(node_modules|bower_components)/,
loader: 'babel',
query: {
presets: ['es2015'],
plugins: [
'transform-object-rest-spread',
'syntax-object-rest-spread',
'transform-es3-property-literals',
'transform-es3-member-expression-literals'
]
}
}
]
},
output: {
filename: `${FILE_NAME}.js`,
libraryTarget: 'umd',
umdNamedDefine: true,
library: MODULE_NAME
},
bail: true
};
var WEBPACK_CONFIG_MIN = Object.assign({}, WEBPACK_CONFIG, {
output: {
filename: `${FILE_NAME}.min.js`,
libraryTarget: 'umd',
umdNamedDefine: true,
library: MODULE_NAME
},
plugins: [
new webpack.optimize.UglifyJsPlugin({
test: /\.js$/,
exclude: /(node_modules|bower_components)/,
minimize: true
})
]
});
gulp.task('webpack', function() {
return gulp.src('src/index.js')
.pipe(gulpWebpack(WEBPACK_CONFIG))
.pipe(gulp.dest('dist'));
});
gulp.task('webpack-min', function() {
return gulp.src('src/index.js')
.pipe(gulpWebpack(WEBPACK_CONFIG_MIN))
.pipe(gulp.dest('dist'));
});