-
Notifications
You must be signed in to change notification settings - Fork 5
/
Gulpfile.js
119 lines (101 loc) · 3.25 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
'use strict';
var childProcess = require('child_process');
var electron = require('electron-prebuilt');
var gulp = require('gulp');
var jetpack = require('fs-jetpack');
var usemin = require('gulp-usemin');
var uglify = require('gulp-uglify');
var minifyCss = require('gulp-minify-css');
var sass = require('gulp-sass');
var gulpLoadPlugins = require('gulp-load-plugins');
var os = require('os');
var gulp_electron = require('gulp-electron');
var packageJson = require('./app/package.json');
var projectDir = jetpack;
var plugins = gulpLoadPlugins();
var srcDir = projectDir.cwd('./app');
var destDir = projectDir.cwd('./build');
// -------------------------------------
// Tasks
// -------------------------------------
gulp.task('clean', function (callback) {
return destDir.dirAsync('.', { empty: true });
});
gulp.task('copy', ['clean'], function () {
return projectDir.copyAsync('app', destDir.path(), {
overwrite: true,
matching: [
'./node_modules/**/*',
'*.html',
'*.css',
'*.svg',
'main.js',
'package.json'
]
});
});
gulp.task('sass', () => {
return gulp.src('./app/sass/*.scss')
.pipe(plugins.plumber())
.pipe(plugins.sourcemaps.init())
.pipe(plugins.autoprefixer('last 10 versions'))
.pipe(plugins.sass({
style: 'compressed'
}))
.pipe(plugins.sourcemaps.write())
.pipe(gulp.dest('./app/assets/css'));
});
gulp.task('sass:watch', function () {
gulp.watch('./app/sass/*.scss', ['sass']);
});
gulp.task('build', ['sass', 'copy'], function () {
return gulp.src('./app/index.html')
.pipe(usemin({
css: [ minifyCss(), 'concat' ],
js: [ uglify() ]
}))
.pipe(gulp.dest('build/'));
});
gulp.task('dev', ['sass'], function () {
childProcess.spawn(electron, ['./app'], { stdio: 'inherit' });
});
gulp.task('run', ['build'], function () {
childProcess.spawn(electron, ['./build'], { stdio: 'inherit' });
});
gulp.task('clean-cache', function (callback) {
return projectDir.cwd('./cache').dirAsync('.', { empty: true });
});
gulp.task('clean-dist', function (callback) {
return projectDir.cwd('./dist').dirAsync('.', { empty: true });
});
gulp.task('dist', ['build', 'clean-dist'], function () {
//platforms Support
//['darwin','win32','linux','darwin-x64','linux-ia32','linux-x64','win32-ia32','win64-64']
var platforms = ['win32-ia32', 'darwin-x64'];
gulp.src("")
.pipe(gulp_electron({
src: './build',
packageJson: packageJson,
release: './dist',
cache: './cache',
version: 'v0.36.7',
packaging: true,
platforms: platforms,
platformResources: {
darwin: {
CFBundleDisplayName: packageJson.name,
CFBundleIdentifier: packageJson.name,
CFBundleName: packageJson.name,
CFBundleVersion: packageJson.version,
icon: 'icon.icns'
},
win: {
"version-string": packageJson.version,
"file-version": packageJson.version,
"product-version": packageJson.version,
'icon': 'icon.ico'
}
}
}))
.pipe(gulp.dest(""));
});