-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
85 lines (68 loc) · 1.98 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/**
* Evemit build tasks
* @author Nicolas Tallefourtane <dev@nicolab.net>
* @link https://github.com/Nicolab/evemit
*/
'use strict';
var gulp = require('gulp');
var uglify = require('gulp-uglify');
var header = require('gulp-header');
var rename = require('gulp-rename');
var livereload = require('gulp-livereload');
var gwebpack = require('gulp-webpack');
var webpack = require('webpack');
var pkg = require('./package.json');
var webpackConf = {
entry: {
main: './test/test.js',
},
output: {
filename: 'test-webpacked.js',
},
externals: {
'unit.js': 'unitjs'
},
plugins: [
new webpack.DefinePlugin({
'process.env': {
// This has effect on the react lib size
'NODE_ENV': JSON.stringify('production')
}
}),
new webpack.optimize.DedupePlugin(),
]
};
/*----------------------------------------------------------------------------*\
Tasks
\*----------------------------------------------------------------------------*/
// build prod
gulp.task('build', function() {
return gulp.src('./evemit.js')
.pipe(uglify())
.pipe(header('/*! '+ pkg.name + ' v'+ pkg.version + ' | '+ pkg.licenses[0].type +
' (c) '+ (new Date().getFullYear()) +' ' + pkg.author.name + ' - ' + pkg.homepage +' */'))
.pipe(rename(function(path) {
path.basename = 'evemit.min';
}))
.pipe(gulp.dest('./'));
});
// Build Unit tests
gulp.task('build-test', function() {
return gulp.src('./test/test.js')
.pipe(gwebpack(webpackConf))
.pipe(rename(function(path) {
path.basename = 'test-webpacked';
}))
.pipe(gulp.dest('./test/'));
});
// dev watch changes
gulp.task('watch', function() {
livereload.listen();
gulp.watch('./test/test.js', ['build-test'])
.on('change', livereload.changed);
gulp.watch('./evemit.js', ['build'])
.on('change', livereload.changed);
});
// bundles
gulp.task('dev', ['build', 'build-test', 'watch']);
gulp.task('default', ['build', 'build-test']);