This repository has been archived by the owner on Oct 9, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
/
gulpfile.js
executable file
·70 lines (62 loc) · 1.99 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
'use strict';
var gulp = require('gulp');
var elm = require('gulp-elm');
var sass = require('gulp-sass');
var cssmin = require('gulp-cssmin');
var browserSync = require('browser-sync');
var prefix = require('gulp-autoprefixer');
var electron = require('electron-connect').server.create();
gulp.task('elm-init', elm.init);
/**
* Copy HTML and CSS files to app directory.
*/
gulp.task("copy-assets", ['sass'], function() {
return gulp.src(["src/*.html", "src/*.css"])
.pipe(gulp.dest("app"))
.pipe(browserSync.reload({stream:true}));
});
/**
* Handle SCSS files.
* Convert SCSS to CSS, minify all the files and add prefix.
*/
gulp.task('sass', function() {
return gulp.src('src/style.scss')
.pipe(sass({
includePaths: ['css'],
onError: browserSync.notify
}))
.pipe(prefix(['last 15 versions', '> 1%', 'ie 8', 'ie 7'], { cascade: true }))
.pipe(cssmin())
.pipe(gulp.dest('app'));
});
/**
* Compile Elm files to JavaScript.
*/
gulp.task('elm', ['elm-init', 'copy-assets'], function(){
return gulp.src('src/*.elm')
.pipe(elm.bundle('app.js'))
.pipe(gulp.dest('app/'))
.pipe(browserSync.reload({stream:true}));
});
/**
* Watch HTML and SCSS files for changes and copy them. In case you have any other assets (i.e. png), put an extra 'src/*.png' or similar to the 'gulp-watch' parameters
* Watch Elm files, recompile them and reload BrowserSync.
*/
gulp.task('watch', function() {
gulp.watch(['src/*.scss', 'src/*.html'], ['copy-assets']);
gulp.watch('src/*.elm', ['elm']);
});
/**
* Build the app without watching the files.
* This task is created for building the app before
* packaging it inside the Electron dist apps.
*/
gulp.task('build', ['elm']);
/**
* Default task, running just `gulp` will compile the SCSS,
* HTML, and Elm, launch BrowserSync and watch files in Electron.
*/
gulp.task('default', ['elm', 'watch'], function() {
// Start browser process
electron.start();
});