-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
108 lines (82 loc) · 3.04 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
'use strict';
const gulp = require('gulp')
const sourcemaps = require('gulp-sourcemaps')
const babel = require("gulp-babel")
const sass = require('gulp-sass')
const googleWebFonts = require('gulp-google-webfonts')
const git = require('gulp-git');
const electron = require('electron-connect').server.create({
"remote-debugging-port": 9992
});
const config = { source: './src' }
config.js2015 = config.source + '/js-dist/'
config.jsNext = config.source + '/js/**/*'
config.sass = config.source + '/themes/default/sass/**/*'
config.css = config.source + '/themes/default/css/'
config.fontsList = config.source + '/themes/googlefonts.list'
config.fontsDest = config.source + '/themes/google-fonts/'
/* Start Tasks */
gulp.task('default', ['production', 'compile-babel', 'compile-sass', 'fonts', 'git-submodules']);
gulp.task('develop', ['set-dev-node-env', 'compile-babel', 'compile-sass'], function () {
electron.start(["--remote-debugging-port=9992"]) // Electron Connect, Auto Reload
gulp.watch(config.sass, ['compile-sass', 'reloadSASS']);
gulp.watch(config.jsNext, ['compile-babel', 'reloadJS']);
});
gulp.task('production', ['set-prod-node-env'], function () {
electron.start() // Electron Connect, Auto Reload
});
/* compile tasks */
gulp.task('compile-babel', function () {
return gulp.src(config.jsNext)
.pipe(sourcemaps.init())
.pipe(babel())
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest(config.js2015));
});
gulp.task('compile-sass', function () {
return gulp.src(config.sass)
.pipe(sass.sync().on('error', sass.logError))
.pipe(gulp.dest(config.css));
});
/* Reload After Compile with Electron Connect */
gulp.task('reloadJS', ['compile-babel'], function () {
console.log('#JS Changed: Reload Electron')
electron.reload()
})
gulp.task('reloadSASS', ['compile-sass'], function () {
console.log('#SASS Changed: Reload Electron')
electron.reload()
})
/** usefull? **/
gulp.task('debug', ['set-debug-node-env'], function () {
electron.start(["--remote-debugging-port=9992"]) // Electron Connect, Auto Reload
gulp.watch(config.sass, ['compile-sass', 'reloadSASS']);
gulp.watch(config.jsNext, ['compile-babel', 'reloadJS']);
});
/**
* Google Webfonts
*/
const googleWebFontsOptions = { };
gulp.task('fonts', function () {
return gulp.src(config.fontsList)
.pipe(googleWebFonts(googleWebFontsOptions))
.pipe(gulp.dest(config.fontsDest));
});
gulp.task('git-submodules', function() {
// Mozilla PDF.JS branch gh-pages
// https://github.com/mozilla/pdf.js/wiki/Setup-PDF.js-in-a-website
// git.addSubmodule('https://github.com/mozilla/pdf.js', 'library/pdfjs-gh-pages', { args: '-b gh-pages'});
});
/**
* NODE_ENV / Environment Variables
* http://stackoverflow.com/questions/28787457/how-can-i-set-an-environment-variable-from-gulp
*/
gulp.task('set-dev-node-env', function() {
return process.env.NODE_ENV = 'development';
});
gulp.task('set-prod-node-env', function() {
return process.env.NODE_ENV = 'production';
});
gulp.task('set-debug-node-env', function() {
return process.env.NODE_ENV = 'debug';
});