forked from stevejhiggs/gulp-webpack-typescript-pipeline
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
54 lines (47 loc) · 1.42 KB
/
index.js
File metadata and controls
54 lines (47 loc) · 1.42 KB
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
const log = require('fancy-log');
const webpack = require('webpack');
const config = require('./webpack.config');
const releaseConfig = require('./webpack.config.release');
const handleWebpackOutput = (err, stats) => {
if (err) throw new gutil.PluginError('tsPipeline', err);
log('[tsPipeline]', stats.toString({
colors: true,
chunks: false
}));
};
const getDevCompiler = (options) => {
return webpack(config(options));
};
const getReleaseCompiler = (options) => {
return webpack(releaseConfig(options));
};
const registerBuildGulpTasks = (gulp, options) => {
gulp.task('tsPipeline:build:dev', (done) => {
const compiler = getDevCompiler(options);
compiler.run((err, stats) => {
handleWebpackOutput(err, stats);
done();
});
});
gulp.task('tsPipeline:build:release', (done) => {
const compiler = getReleaseCompiler(options);
compiler.run((err, stats) => {
handleWebpackOutput(err, stats);
done();
});
});
gulp.task('tsPipeline:watch', [], () => {
const compiler = getDevCompiler(options);
compiler.watch({
aggregateTimeout: 300, // wait so long for more changes
poll: 2000 // windows needs polling to pick up changes :(
}, (err, stats) => {
handleWebpackOutput(err, stats);
});
});
};
module.exports = {
registerBuildGulpTasks: registerBuildGulpTasks,
getDevCompiler: getDevCompiler,
getReleaseCompiler: getReleaseCompiler
};