forked from c4wrd/angular2-electron-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
151 lines (131 loc) · 3.79 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
"use strict";
var gulp = require('gulp'),
del = require('del'),
electron = require('gulp-atom-electron'),
symdest = require('gulp-symdest'),
sass = require('gulp-sass'),
shell = require('gulp-shell'),
config = require("./project-config"),
runSeq = require('run-sequence');
/**
* Cleans our distribution folder
*/
gulp.task('electron:clean', function () {
return del('dist/**/*', {force: true});
});
/**
* Copies the following into the distribution folder:
* 1. Node modules that are needed for distribution
* 2. Bower packages needed for distribution
* 3. Any other remaining files in our `src`
* directory
*/
gulp.task('electron:copy', () => {
var fs_setup = [
{ // copy assets from our source to distribution
from: ['./src/**/*', '!./src/**/*.scss', '!./src/**/*.ts'],
to: './dist'
}
];
config.VENDOR_FILES.forEach((item) => {
let SOURCE = item.source;
let FILES = SOURCE.concat("/").concat(item.files);
fs_setup.push({
from: `node_modules/${FILES}`,
to: `./dist/assets/vendor/${SOURCE}`
})
});
if ( config.BOWER_PACKAGES ) {
config.BOWER_PACKAGES.forEach((item) => {
let SOURCE = item.source;
let FILES = SOURCE.concat("/").concat(item.files);
fs_setup.push({
from: `./bower_components/${FILES}`,
to: `./dist/assets/bower/${SOURCE}`
})
});
}
return fs_setup.map((setup) => {
return gulp.src(setup.from).pipe(gulp.dest(setup.to));
});
});
/**
* Transpiles our Sass classes into CSS and
* places it in the matching folder hierarchy in
* the distribution folder.
*/
gulp.task('electron:transpile:sass', function () {
gulp.src('./src/**/*.scss')
.pipe(sass().on('error', sass.logError))
.pipe(gulp.dest('./dist'));
});
/**
* Watches our Sass files for changes
* and transpiles edited files and places
* them in the distribution folder.
*/
gulp.task("sass:watch", function () {
gulp.watch('./src/**/*.scss', ['electron:transpile:sass']);
});
/**
* Transpiles TypeScript to JavaScript
*/
gulp.task('electron:transpile:ts', shell.task(['tsc']));
/**
* Watches our TypeScript files, invoking the `tsc` compiler
* if changes are detected.
*/
gulp.task("typescript:watch", function () {
gulp.watch('./src/**/*.ts', ['electron:transpile:ts']);
});
/**
* Builds the OSX application and places it in our
* 'packages' folder
*/
gulp.task('electron:build:osx', function () {
gulp.src(['dist/**/*'])
.pipe(electron({
version: '1.3.3',
platform: 'darwin'
}))
.pipe(symdest('packages/osx'));
});
/**
* Builds the Linux application and places it in our
* 'packages' folder
*/
gulp.task('electron:build:linux', function () {
gulp.src(['dist/**/*'])
.pipe(electron({
version: '1.3.3',
platform: 'linux'
}))
.pipe(symdest('packages/linux'));
});
/**
* Builds the Windows executable file and places it in our
* 'packages' folder
*/
gulp.task('electron:build:win', function () {
gulp.src(['dist/**/*'])
.pipe(electron({
version: '1.3.3',
platform: 'win32'
}))
.pipe(symdest('packages/win'));
});
/**
* Umbrella task for executing our build
*/
gulp.task('electron:build', function (done) {
return runSeq('electron:clean', 'electron:copy', 'electron:transpile:sass', 'electron:transpile:ts', done);
});
/**
* Task for packing our application for OS distribution
*/
gulp.task('electron:package', (done) => {
return runSeq('build',
['electron:build:win', 'electron:build:osx', 'electron:build:linux'], done);
});
gulp.task('build', ['electron:build']);
gulp.task('default', ['build']);