This repository has been archived by the owner on Jun 5, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
103 lines (91 loc) · 2.65 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
var gulp = require('gulp'),
mocha = require('gulp-mocha'),
runSequence = require('gulp-run-sequence'),
rimraf = require('rimraf'),
fs = require('fs-extra');
var gutil = require("gulp-util"),
webpack = require("webpack"),
webpackConfig = require("./webpack.config.js"),
packageConfig = require('./package.json');
gulp.task("dist", function(cb) {
runSequence(
'dist:clean',
'dist:package:debug',
'dist:package:release',
'dist:package:latest-entry',
cb);
});
gulp.task("dist:package:latest-entry", function(cb) {
fs.copy("dist/winjsrocks-plugin-platform-" + packageConfig.version + ".js", "dist/latest.js", cb);
});
gulp.task("dist:package:release", function(cb) {
// modify some webpack config options
var myConfig = Object.create(webpackConfig);
myConfig.plugins = myConfig.plugins || [];
myConfig.plugins = myConfig.plugins.concat(
new webpack.DefinePlugin({
"process.env": {
// This has effect on the react lib size
"NODE_ENV": JSON.stringify("production")
}
}),
new webpack.optimize.DedupePlugin(),
new webpack.optimize.UglifyJsPlugin()
);
myConfig.output.filename = "dist/winjsrocks-plugin-platform-" + packageConfig.version + ".js";
// run webpack
webpack(myConfig, function(err, stats) {
if (err) throw new gutil.PluginError("webpack:build", err);
gutil.log("[webpack:build]", stats.toString({
colors: true
}));
cb();
});
});
gulp.task("dist:package:debug", function(cb) {
// modify some webpack config options
var myDevConfig = Object.create(webpackConfig);
myDevConfig.devtool = "sourcemap";
myDevConfig.debug = true;
myDevConfig.output.filename = "dist/winjsrocks-plugin-platform-" + packageConfig.version + ".debug.js";
// create a single instance of the compiler to allow caching
var devCompiler = webpack(myDevConfig);
// run webpack
devCompiler.run(function(err, stats) {
if (err) throw new gutil.PluginError("webpack:build-dev", err);
gutil.log("[webpack:build-dev]", stats.toString({
colors: true
}));
cb();
});
});
gulp.task("test", function() {
return gulp.src('test/**/*.js', {
read: false
})
.pipe(mocha({
reporter: 'spec',
timeout: 60000
}));
});
gulp.task("test:integration", function() {
return gulp.src('test/integration/**/*.js', {
read: false
})
.pipe(mocha({
reporter: 'spec',
timeout: 60000
}));
});
gulp.task("test:unit", function() {
return gulp.src('test/unit/**/*.js', {
read: false
})
.pipe(mocha({
reporter: 'spec',
timeout: 60000
}));
});
gulp.task("dist:clean", function(cb) {
rimraf('./dist', cb);
});