-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathgulpfile.js
88 lines (75 loc) · 2.43 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
86
87
88
const gulp = require('gulp');
const mocha = require('gulp-mocha-phantomjs');
const webpack = require('webpack');
const gutil = require('gutil');
const beep = require('beepbeep');
const config = require("./webpack.config.js");
const packageJson = require('./package.json');
const libraryName = '$ajaxCache';
gulp.task('default', ['build-dev', 'build-prod'], function (callback) {
gulp.watch('./src/**/*', ['build-dev', 'build-prod']);
});
gulp.task('test', function () {
return gulp.src('./test/**/*.html', {read: false})
.pipe(mocha());
});
gulp.task('build-dev', function (callback) {
var BANNER = ' ' + packageJson.name + ' -- ' + packageJson.description + '\n' +
' Version ' + packageJson.version + '\n' +
' https://github.com/WQTeam/jquery-ajax-cache\n' +
' (c) 2013-2016 WQTeam, MIT license\n';
config.output = {
libraryTarget: 'umd',
path: './dist/',
filename: 'jquery-ajax-cache.js',
library: libraryName
}
config.entry = './src/index';
config.plugins = [
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.BannerPlugin(BANNER)
];
// run webpack
webpack(config, function(err, stats) {
if(stats.hasErrors()) {
beep();
}
gutil.log("build-dev", stats.toString({
colors: true
}));
callback();
});
});
gulp.task('build-prod', function (callback) {
var BANNER = ' ' + packageJson.name + ' -- ' + packageJson.description + '\n' +
' Version ' + packageJson.version + '\n' +
' https://github.com/WQTeam/jquery-ajax-cache\n' +
' (c) 2013-2015 WQTeam, MIT license\n';
config.output = {
path: './dist/',
libraryTarget: "umd",
filename: 'jquery-ajax-cache.min.js',
library: libraryName
}
config.entry = './src/index';
config.plugins = [
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.optimize.UglifyJsPlugin({
compressor: {
warnings: false
},
comments: false
}),
new webpack.BannerPlugin(BANNER)
];
// run webpack
webpack(config, function(err, stats) {
if(stats.hasErrors()) {
beep();
}
gutil.log("build-prod", stats.toString({
colors: true
}));
callback();
});
});