-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathgulpfile.js
77 lines (62 loc) · 2 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
/*
* created by aditya on 21/09/17
*/
"use strict";
const gulp = require("gulp");
const webpack = require("webpack");
const loadPlugins = require("gulp-load-plugins");
const rimraf = require("rimraf");
const popupWebpackConfig = require("./popup/webpack.config");
const eventWebpackConfig = require("./event/webpack.config");
const contentWebpackConfig = require("./content/webpack.config");
const plugins = loadPlugins();
gulp.task('popup-js', ['clean'], (cb) => {
webpack(popupWebpackConfig, (err, stats) => {
if(err) {
throw new plugins.util.PluginError('webpack', err);
}
plugins.util.log('[webpack]', stats.toString());
cb();
});
});
gulp.task('event-js', ['clean'], (cb) => {
webpack(eventWebpackConfig, (err, stats) => {
if(err) {
throw new plugins.util.PluginError('webpack', err);
}
plugins.util.log('[webpack]', stats.toString());
cb();
});
});
gulp.task('content-js', ['clean'], (cb) => {
webpack(contentWebpackConfig, (err, stats) => {
if(err) {
throw new plugins.util.PluginError('webpack', err);
}
plugins.util.log('[webpack]', stats.toString());
cb();
});
});
gulp.task('popup-html', ['clean'], () => {
return gulp.src('popup/src/index.html')
.pipe(plugins.rename('popup.html'))
.pipe(gulp.dest('./build'))
});
gulp.task('popup-images', ['clean'], () => {
return gulp.src('popup/src/images/*')
.pipe(gulp.dest('./build/popup-images'))
});
gulp.task('copy-manifest', ['clean'], () => {
return gulp.src('manifest.json')
.pipe(gulp.dest('./build'));
});
gulp.task('clean', (cb) => {
rimraf('./build', cb);
});
gulp.task('build', ['copy-manifest', 'popup-js', 'popup-html', 'popup-images', 'event-js', 'content-js']);
gulp.task('watch', ['default'], () => {
gulp.watch('popup/**/*', ['build']);
gulp.watch('content/**/*', ['build']);
gulp.watch('event/**/*', ['build']);
});
gulp.task('default', ['build']);