-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
52 lines (44 loc) · 1.1 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
var gulp = require('gulp');
var elm = require('gulp-elm');
var gutil = require('gulp-util');
var plumber = require('gulp-plumber');
var connect = require('gulp-connect');
//file paths
var paths = {
dest: 'dist',
elm: 'src/*.elm',
static: 'src/*.{html,css}'
};
//init elm
gulp.task('elm-init', elm.init);
//compile elm to html
gulp.task('elm', ['elm-init'], function() {
return gulp.src(paths.elm)
.pipe(plumber())
.pipe(elm())
.pipe(gulp.dest(paths.dest))
.pipe(connect.reload());
});
//move static assets to dist
gulp.task('static', function() {
return gulp.src(paths.static)
.pipe(plumber())
.pipe(gulp.dest(paths.dest))
.pipe(connect.reload());
});
//watch for changes
gulp.task('watch', function() {
gulp.watch(paths.elm, ['elm']);
gulp.watch(paths.static, ['static']);
});
//create server
gulp.task('connect', function() {
connect.server({
root: 'dist',
livereload: true,
port: 5050
});
});
//main tasks
gulp.task('build', ['elm', 'static']);
gulp.task('default', ['connect', 'build', 'watch']);