forked from MyEtherWallet/etherwallet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
207 lines (150 loc) · 5.34 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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
// confirmed working on node v4.2.6 & npm v3.7.2
// if you are still having issues, you may need to install browserify gloablly.
var fs = require('fs');
var gulp = require('gulp');
var less = require('gulp-less');
var autoprefixer = require('gulp-autoprefixer');
var cssnano = require('gulp-cssnano');
var notify = require('gulp-notify');
var rename = require('gulp-rename');
var gutil = require('gulp-util');
var concat = require('gulp-concat');
var clean = require('gulp-clean');
var uglify = require('gulp-uglify');
var shell = require('gulp-shell');
var fileinclude = require('gulp-file-include');
// Compile and Minify Less / CSS Files
var lessWatchFolder = './app/styles/less/**/*.less';
var lessFile = './app/styles/less/etherwallet-master.less';
var lessOutputFolder = './dist/css';
var cxLessOutputFolder = './chrome-extension/css';
var lessOutputFile = 'etherwallet-master.css';
var lessOutputFileMin = 'etherwallet-master.min.css';
gulp.task('less', function (cb) {
return gulp
.src(lessFile)
.pipe(less({ compress: false })).on('error', notify.onError(function (error) {
return "ERROR! Problem file : " + error.message;
}))
.pipe(autoprefixer('last 2 version', 'ios 6', 'android 4'))
.pipe(rename(lessOutputFile))
//.pipe(gulp.dest(lessOutputFolder)) // unminified css
//.pipe(gulp.dest(cxLessOutputFolder)) // unminified css
.pipe(cssnano()).on('error', notify.onError(function (error) {
return "ERROR! minify CSS Problem file : " + error.message;
}))
.pipe(rename(lessOutputFileMin))
//mew css
.pipe(gulp.dest(lessOutputFolder))
.pipe(notify('MEW Styles Complete'))
//cx css
.pipe(gulp.dest(cxLessOutputFolder))
.pipe(notify('CX Styles Complete'));
});
// Compile and Minify JS Files
var jsFiles = "./app/scripts/*.js";
var AllJsFiles = "./app/scripts/**/*.js";
var mainjs = "./app/scripts/main.js";
var staticjsFiles = "./app/scripts/staticJS/*.js";
var staticjsOutputFile = 'etherwallet-static.min.js';
gulp.task('staticJS', function () {
return gulp
.src(staticjsFiles)
.pipe(concat(staticjsOutputFile))
.pipe(uglify())
// mew static
.pipe(gulp.dest('./dist/js/'))
.pipe(notify('MEW StaticJS Complete'))
// mew staticxc
.pipe(gulp.dest('./chrome-extension/js/'))
.pipe(notify('CX StaticJS Complete'));
});
gulp.task('minJS',['browserify'],function () {
return gulp
.src('./dist/js/etherwallet-master.js')
.pipe(concat('etherwallet-master-min.js'))
.pipe(gulp.dest('./dist/js/'))
.pipe(notify('MEW MinJS'));
});
gulp.task('cxMinJS',['cxBrowserify'],function () {
return gulp
.src('./chrome-extension/js/etherwallet-master.js')
.pipe(concat('etherwallet-master-min.js'))
.pipe(gulp.dest('./chrome-extension/js/'))
.pipe(notify('CX MinJS'));
});
// Browserify
gulp.task('browserify', shell.task([
'browserify '+mainjs+' -o dist/js/etherwallet-master.js'
]));
gulp.task('cxBrowserify', shell.task([
'browserify '+mainjs+' -o chrome-extension/js/etherwallet-master.js'
]));
// Copy Images
var imagesFolder = "./app/images/**/*";
var imagesOutputFolder = "./dist/images";
var cxImagesOutputFolder = "./chrome-extension/images";
gulp.task('copy-images', function() {
gulp.src(imagesFolder)
.pipe(gulp.dest(imagesOutputFolder))
.pipe(notify({message:'MEW Images', onLast:true}))
.pipe(gulp.dest(cxImagesOutputFolder))
.pipe(notify({message:'CX Images', onLast:true}));
});
// Copy Fonts
var fontsFolder = "./app/fonts/*.*";
var fontsOutputFolder = "./dist/fonts";
var cxFontsOutputFolder = "./chrome-extension/fonts";
gulp.task('copy-fonts', function() {
gulp.src(fontsFolder)
.pipe(gulp.dest(fontsOutputFolder))
.pipe(notify({message:'MEW Fonts', onLast:true}))
.pipe(gulp.dest(cxFontsOutputFolder))
.pipe(notify({message:'CX Fonts', onLast:true}));
});
// Copy CX Browser Action Files
var cxSource = "./app/includes/browser_action/*.*";
var cxDest = "./chrome-extension/browser_action";
gulp.task('copy-cx', function() {
gulp.src( cxSource )
.pipe(gulp.dest( cxDest ))
.pipe(notify({message:'CX Browser Action Files', onLast:true}))
});
//html Pages
var htmlPages = "./app/layouts/*.html";
var tplFiles = "./app/includes/*.tpl";
gulp.task('buildHTML', function () {
gulp.src(htmlPages)
.pipe(fileinclude({
prefix: '@@',
basepath: '@file'
}))
.pipe(gulp.dest('./dist/'))
.pipe(notify({message:'MEW HTML Pages Complete', onLast:true}))
.pipe(gulp.dest('./chrome-extension/'))
.pipe(notify({message:'CX HTML Pages Complete', onLast:true}));
});
// Watch Tasks
gulp.task('watchJS', function() {
gulp.watch([jsFiles, AllJsFiles],[
'browserify',
'cxBrowserify',
'minJS',
'cxMinJS'
]);
});
gulp.task('watchLess', function() {
gulp.watch(lessWatchFolder, ['less']);
});
gulp.task('watchPAGES', function() {
gulp.watch(htmlPages, ['buildHTML']);
});
gulp.task('watchTPL', function() {
gulp.watch(tplFiles, ['buildHTML']);
});
gulp.task('watchCX', function() {
gulp.watch(cxSource, ['copy-cx']);
});
gulp.task('build', ['buildHTML','less', 'staticJS', 'browserify', 'cxBrowserify', 'minJS', 'cxMinJS', 'copy-images','copy-fonts', 'copy-cx']);
gulp.task('watch', ['watchJS' , 'watchLess', 'watchPAGES', 'watchTPL', 'watchCX']);
gulp.task('default', ['build', 'watch']);