forked from MyEtherWallet/etherwallet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
158 lines (139 loc) · 4.82 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
// 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');
// less
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');
// less vars
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';
//html Pages
var htmlPages = "./app/layouts/*.html";
var tplFiles = "./app/includes/*.tpl";
//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';
//images
var imagesFolder = "./app/images/**/*";
var imagesOutputFolder = "./dist/images";
var cxImagesOutputFolder = "./chrome-extension/images";
//fonts
var fontsFolder = "./app/fonts/*.*";
var fontsOutputFolder = "./dist/fonts";
var cxFontsOutputFolder = "./chrome-extension/fonts";
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))
.pipe(gulp.dest(cxLessOutputFolder))
.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'));
});
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'
]));
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 static
.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'));
});
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}));
});
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}));
});
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('build', ['copy-images','copy-fonts','buildHTML','less', 'staticJS', 'browserify', 'cxBrowserify', 'minJS', 'cxMinJS']);
gulp.task('watch', ['watchJS' , 'watchLess', 'watchPAGES', 'watchTPL']);
gulp.task('default', ['build', 'watch']);