forked from newhouse/url-tracking-stripper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
188 lines (134 loc) · 4.05 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
'use strict';
const gulp = require('gulp');
const webpackStream = require('webpack-stream');
const webpack = require('webpack');
const webpackConfig = require('./webpack.config.js');
const zip = require('gulp-zip');
const clean = require('gulp-clean');
const runSequence = require('run-sequence');
const TARGET_DIR = 'chrome';
const TARGET_UGLIFIED_DIR = 'chrome_uglified';
// CLEAN
gulp.task('clean', function () {
return gulp.src(`${TARGET_DIR}/`, {read: false})
.pipe(clean());
});
// CLEAN UGLIFIED
gulp.task('clean-uglified', function () {
return gulp.src(`${TARGET_UGLIFIED_DIR}/`, {read: false})
.pipe(clean());
});
// IMAGES
gulp.task('images', function() {
return gulp.src('./assets/images/**/*.*')
.pipe(gulp.dest(`./${TARGET_DIR}/public/images/`));
});
// IMAGES FOR UGLIFIED
gulp.task('images-uglified', function() {
return gulp.src('./assets/images/**/*.*')
.pipe(gulp.dest(`./${TARGET_UGLIFIED_DIR}/public/images/`));
});
// LIB
gulp.task('lib', function() {
return gulp.src('./assets/lib/**/*.*')
.pipe(gulp.dest(`./${TARGET_DIR}/public/lib/`));
});
// LIB FOR UGLIFIED
gulp.task('lib-uglified', function() {
return gulp.src('./assets/lib/**/*.*')
.pipe(gulp.dest(`./${TARGET_UGLIFIED_DIR}/public/lib/`));
});
// HTML
gulp.task('html', function() {
return gulp.src('./assets/**.html')
.pipe(gulp.dest(`./${TARGET_DIR}`));
});
// HTML FOR UGLIFIED
gulp.task('html-uglified', function() {
return gulp.src('./assets/*.html')
.pipe(gulp.dest(`./${TARGET_UGLIFIED_DIR}`));
});
// FAVICON
gulp.task('favicon', function() {
return gulp.src('./assets/images/favicon/dev/**.*')
.pipe(gulp.dest(`./${TARGET_DIR}/public/images/favicon/`));
});
// FAVICON FOR UGLIFIED
gulp.task('favicon-uglified', function() {
return gulp.src('./assets/images/favicon/production/**.*')
.pipe(gulp.dest(`./${TARGET_UGLIFIED_DIR}/public/images/favicon/`));
});
// MANIFEST
gulp.task('manifest', function() {
return gulp.src('./assets/manifest.json')
.pipe(gulp.dest(`./${TARGET_DIR}`));
});
// MANIFEST FOR UGLIFIED
gulp.task('manifest-uglified', function() {
return gulp.src('./assets/manifest.json')
.pipe(gulp.dest(`./${TARGET_UGLIFIED_DIR}`));
});
// MOVE FOR DEV
gulp.task('move', ['images', 'lib', 'html', 'favicon', 'manifest']);
// MOVE FOR UGLIFIED
gulp.task('move-uglified', ['images-uglified', 'lib-uglified', 'html-uglified', 'favicon-uglified', 'manifest-uglified']);
// WEBPACK
gulp.task('webpack', function() {
// PACK NON-UGLIFIED
return gulp.src('./assets')
.pipe(webpackStream(webpackConfig.debug, webpack))
.pipe(gulp.dest(`./${TARGET_DIR}/public/js`));
});
// WEBPACK FOR UGLIFIED
gulp.task('webpack-uglified', function() {
// PACK PROD UGLIFIED
return gulp.src('./assets')
.pipe(webpackStream(webpackConfig.uglified, webpack))
.pipe(gulp.dest(`./${TARGET_UGLIFIED_DIR}/public/js`));
});
/*
* NON-UGLIFIED BUILD PROCESS
*
* $ gulp dev
*/
// BUILD AND WATCH NON-UGLIFIED
gulp.task('dev', function() {
runSequence('clean', 'move', 'webpack');
gulp.watch('./assets/**/*', ['webpack']);
gulp.watch('./assets/**.html', ['html']);
gulp.watch('./assets/manifest.json', ['manifest']);
console.log('Watching...');
});
// BUILD AND ZIP NON-UGLIFIED
gulp.task('build', function() {
runSequence('clean', 'move', 'webpack', 'zip');
});
/*
* UGLIFIED BUILD PROCESS
*
* $ gulp
*/
// BUILD AND ZIP UGLIFIED
gulp.task('default', function() {
runSequence('clean-uglified', 'move-uglified', 'webpack-uglified', 'zip-uglified');
});
// ZIP
gulp.task('zip', function() {
return gulp.src(`./${TARGET_DIR}/**/*`)
.pipe(zip('chrome_extension.zip'))
.pipe(gulp.dest('./'));
});
// ZIP UP THE UGLIFIED VERSION
gulp.task('zip-uglified', function() {
return gulp.src(`./${TARGET_UGLIFIED_DIR}/**/*`)
.pipe(zip('chrome_extension-uglified.zip'))
.pipe(gulp.dest('./'));
});
/*
* SET ENVIRONMENT
*
*/
// gulp.task('production-env', function() {
// return process.env.NODE_ENV = 'production';
// });
module.exports = gulp;