Skip to content

Commit 150cf82

Browse files
committed
fix: reduce app size
1 parent 917f09d commit 150cf82

File tree

3 files changed

+28
-9
lines changed

3 files changed

+28
-9
lines changed

gulpfile.js

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ var plugins = require("gulp-load-plugins")({lazy: false});
33
var fs = require('fs');
44
var path = require('path');
55
var os =require('os');
6+
var del = require('del');
67
var minimist = require('minimist')
78
//var NwBuilder = require('nw-builder');
89
//var pkg = require('./package');
@@ -178,7 +179,7 @@ gulp.task('copy-static', function () {
178179
// });
179180

180181
gulp.task('copy-index', function () {
181-
gulp.src(['./app/index.html',
182+
return gulp.src(['./app/index.html',
182183
'./main.js',
183184
'./server.js',
184185
'./vendor/*.js',
@@ -188,9 +189,9 @@ gulp.task('copy-index', function () {
188189
.pipe(gulp.dest(DIST));
189190
});
190191

191-
gulp.task('gen-package', function () {
192-
gulp.src(['./package.json'])
193-
.on('end', function(){
192+
gulp.task('gen-package', ['copy-index'], function () {
193+
return gulp.src(['./package.json'])
194+
.on('end', function(cb){
194195
var info = require('./package');
195196

196197
delete info.devDependencies;
@@ -208,11 +209,17 @@ gulp.task('gen-package', function () {
208209

209210
try{ fs.statSync(DIST); }catch(e){ fs.mkdirSync(DIST); }
210211
fs.writeFileSync(DIST+'/package.json', JSON.stringify(info,' ',2));
211-
exec('cd dist && yarn install --production=true && yarn autoclean --force');
212-
// exec('cd dist && cnpm i');
212+
exec('cd dist && yarn install --prod && yarn autoclean --force', cb);
213213
});
214214
});
215215

216+
gulp.task('remove-redundant', ['gen-package'], function (cb) {
217+
return del.sync([
218+
'dist/node_modules/protobufjs/dist',
219+
'dist/node_modules/aliyun-sdk/dist'
220+
]);
221+
})
222+
216223

217224

218225
gulp.task('watch', function () {
@@ -255,6 +262,6 @@ gulp.task('watch', function () {
255262
// livereload: true
256263
// }));
257264

258-
gulp.task('build', ['js', 'templates', 'css', 'copy-index', 'libJS', 'libCSS', 'copy-fonts','copy-node','copy-docs','copy-icons','copy-static','gen-package']);
265+
gulp.task('build', ['js', 'templates', 'css', 'copy-index', 'libJS', 'libCSS', 'copy-fonts','copy-node','copy-docs','copy-icons','copy-static','gen-package', 'remove-redundant']);
259266

260267
gulp.task('default', [ 'build', 'watch']);

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,11 @@
2727
"babel-preset-es2015": "^6.24.1",
2828
"bootstrap": "3.3.6",
2929
"bower": "~1.7.9",
30+
"clipboard": "^1.7.1",
3031
"codemirror": "^5.19.0",
3132
"commander": "~2.9.0",
3233
"cross-env": "^3.1.4",
34+
"del": "^4.1.1",
3335
"electron": "1.8.4",
3436
"electron-packager": "7.1.0",
3537
"font-awesome": "^4.7.0",
@@ -55,8 +57,7 @@
5557
"spectron": "^3.7.2"
5658
},
5759
"dependencies": {
58-
"aliyun-sdk": "^1.12.0",
59-
"clipboard": "^1.7.1",
60+
"aliyun-sdk": "^1.12.3",
6061
"electron-log": "1.3.0",
6162
"koa": "^2.3.0",
6263
"koa-convert": "^1.2.0",

tools/.yarnclean

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
11
*.yaml
22
*.md
3+
*.ts
4+
*.bak
5+
*.png
6+
*.jpg
7+
*.svg
8+
*.coffee
9+
*.map
10+
tsconfig.json
311
LICENSE
12+
AUTHORS
13+
Makefile
14+
package-lock.json

0 commit comments

Comments
 (0)