-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
146 lines (124 loc) · 3.4 KB
/
Copy pathgulpfile.js
File metadata and controls
146 lines (124 loc) · 3.4 KB
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
'use strict';
const path = require('path');
const browserify = require('browserify');
const gulp = require('gulp');
const source = require('vinyl-source-stream');
const buffer = require('vinyl-buffer');
const gutil = require('gulp-util');
const reactify = require('reactify');
const envify = require('envify/custom');
const del = require('del');
const minifier = require('gulp-uglify/minifier');
const uglifyJS = require('uglify-js');
const packager = require('electron-packager');
gulp.task('clean', function (cb) {
del(['dist', 'release'], cb);
});
gulp.task('bundle-index', function () {
const b = browserify({
entries: './src/index.js',
debug: false,
node: true,
bundleExternal: false,
transform: [reactify, envify({
NODE_ENV: 'production'
})]
});
const options = {
preserveComments: 'license',
// FIXME: if mangle is set to true, then I get "SyntaxError: Identifier 'n' has already been declared" ?!
// it's not needed, but it would be nice if it worked :)
mangle: false
};
return b.bundle()
.pipe(source('index.js'))
.pipe(buffer())
// FIXME turn off .pipe(minifier(options, uglifyJS))
.pipe(gulp.dest('./dist/'));
});
gulp.task('bundle-worker', function () {
const b = browserify({
entries: './src/worker.js',
debug: false,
node: true,
bundleExternal: false,
transform: [reactify, envify({
NODE_ENV: 'production'
})]
});
return b.bundle()
.pipe(source('worker.js'))
.pipe(buffer())
.pipe(gulp.dest('./dist/'));
});
gulp.task('html', function () {
return gulp.src(['./src/index.html', './src/splash.html', './src/worker.html'])
.pipe(gulp.dest('dist'));
});
gulp.task('assets', function () {
return gulp.src('./src/assets/**/*', {"base": "./src"})
.pipe(gulp.dest('dist'));
});
gulp.task('default', ['html', 'assets', 'bundle-index', 'bundle-worker']);
// PACKAGING
function getPackOptions(opts) {
return Object.assign({
dir: '.',
asar: false,
version: '1.4.5',
//platform: '',
//arch: '',
out: 'release',
overwrite: true,
prune: true,
ignore: [
'^/.idea',
'^/release',
'^/src',
'^/test',
'^/.gitignore',
'^/gulpfile.js',
'^/readme-res',
'^/README.md'
]
}, opts);
}
gulp.task('pack-mac', function () {
const options = getPackOptions({
platform: 'darwin',
arch: 'x64',
});
return packager(options, (err, appPaths) => {
if (err) {
console.log(err);
} else {
console.log('Done', appPaths);
}
});
});
gulp.task('pack-win', function () {
const options = getPackOptions({
platform: 'win32',
arch: 'x64',
});
return packager(options, (err, appPaths) => {
if (err) {
console.log(err);
} else {
console.log('Done', appPaths);
}
});
});
gulp.task('pack-lin', function () {
const options = getPackOptions({
platform: 'linux',
arch: 'x64',
});
return packager(options, (err, appPaths) => {
if (err) {
console.log(err);
} else {
console.log('Done', appPaths);
}
});
});