-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
39 lines (36 loc) · 1.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
//const spawn = require('child_process').spawn;
const spawn = require('cross-spawn');
const gulp = require('gulp');
const babel = require('gulp-babel');
const postcss = require('gulp-postcss');
const cssnano = require('cssnano')
const path = require('path');
// 1. Copy the index.html as is
gulp.task('html', () => {
return gulp.src('src/index.html')
.pipe(gulp.dest('app/'));
});
// 2. Compile CSS file and move them to the app folder
gulp.task('css', function() { // 2.
var plugins = [
cssnano
];
return gulp.src('src/contents/style/*.css')
.pipe(postcss(plugins))
.pipe(gulp.dest('app/contents/style/'));
});
// 3. Compile JS files and move them to the app folder
gulp.task('js', () => { // 3.
return gulp.src(['src/**/**/*.js'])
.pipe(babel())
.pipe(gulp.dest('app/'));
});
// 4. Start the electron process.
const cmd = (name) => path.join(__dirname + `/node_modules/.bin/${name}`);
//const cmd = (name) => name;
const args = (more) => Array.isArray(more) ? ['.'].concat(more) : ['.'];
const exit = () => process.exit();
gulp.task('start', gulp.series('html', 'css', 'js', () => { // 4.
spawn(cmd('electron'), args(), { stdio: 'inherit' }).on('close', exit);
return Promise.resolve();
}));