-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.babel.js
99 lines (85 loc) · 2.43 KB
/
gulpfile.babel.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
import gulp from 'gulp';
import del from 'del';
import babel from 'gulp-babel';
import babelify from 'babelify';
import sass from 'gulp-sass';
import watch from 'gulp-watch';
import plumber from 'gulp-plumber';
import browserify from 'browserify';
import sourcemaps from 'gulp-sourcemaps';
import electronConnect from 'electron-connect';
import packager from 'electron-packager';
import source from 'vinyl-source-stream';
const js = './src/**/*.js';
const scss = './src/**/*.scss';
const html = './src/**/*.html';
const pacagejson = './package.json';
gulp.task('clean', () => {
return del.sync(['./lib']);
});
gulp.task('package', (cb) => {
return packager({
name: 'markit',
dir: '.',
out: 'lib/bin',
overwrite: true,
prune: true,
arch: 'x64',
platform: 'darwin',
icon: 'icons/note.icns'
}, (err, path) => {
cb();
});
});
gulp.task('package.json', () => {
return gulp.src(pacagejson)
.pipe(gulp.dest('./lib/'));
});
gulp.task('js', () => {
return gulp.src(js)
.pipe(sourcemaps.init())
.pipe(plumber())
.pipe(babel())
.pipe(sourcemaps.write("."))
.pipe(gulp.dest('./lib/'));
});
gulp.task('js:prod', () => {
browserify({entyries: ['./src/app.js'], debug: true})
.transform(babelify.configure({
presets: ["es2015", "stage-0", "react"]}))
.bundle()
.on("error", function (err) { console.log("Error : " + err.message); })
.pipe(source('app.js'))
.pipe(gulp.dest('./lib/'));
});
gulp.task('scss', () => {
return gulp.src(scss)
.pipe(plumber())
.pipe(sass())
.pipe(gulp.dest('./lib/'));
});
gulp.task('html', () => {
return gulp.src(html)
.pipe(plumber())
.pipe(gulp.dest('./lib/'));
});
gulp.task('build:prod', ['js:prod', 'html', 'scss', 'package.json'], (done) => {
done()
});
gulp.task('build:debug', ['js', 'html', 'scss', 'package.json'], (done) => {
done()
});
gulp.task('continuous:watch', ['js', 'html', 'scss', 'package.json'], () => {
watch([pacagejson], () => gulp.start('package.json'));
watch([js], () => gulp.start('js'));
watch([html], () => gulp.start('html'));
watch([scss], () => gulp.start('scss'));
});
gulp.task('server', ['watch'], () => {
const electron = electronConnect.server.create();
electron.start();
watch(['lib/*.js'], electron.restart);
watch(['lib/renderer/**/*.{html,js,css}'], electron.reload);
});
gulp.task('watch', ['continuous:watch']);
gulp.task('default', ['js', 'html', 'scss', 'package.json']);