-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
72 lines (60 loc) · 1.59 KB
/
gulpfile.js
File metadata and controls
72 lines (60 loc) · 1.59 KB
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
var gulp = require('gulp');
var elm = require('gulp-elm');
var rename = require('gulp-rename');
var concat = require('gulp-concat');
var browserSync = require('browser-sync').create();
var argv = require('yargs').argv;
var paths = {
html: 'src/index.html',
elmMain: 'src/Main.elm',
elm: 'src/**/*.elm',
css: 'src/css/**/*.css'
}
function swallowError (error) {
console.log(error.toString());
this.emit('end');
}
gulp.task('elm-init', elm.init);
gulp.task('elm', ['elm-init'], function() {
return gulp.src(paths.elmMain)
.pipe(elm())
.on('error', swallowError)
.pipe(rename("main.js"))
.pipe(gulp.dest('dist/'));
});
gulp.task('html', function() {
return gulp.src(paths.html)
.pipe(gulp.dest('dist'))
});
gulp.task('css', function() {
return gulp.src(paths.css)
.pipe(concat('cat.css'))
.pipe(gulp.dest('dist/css'))
});
gulp.task('font', function() {
return gulp.src('src/font/*')
.pipe(gulp.dest('dist/font'))
});
gulp.task('img', function() {
return gulp.src('src/img/*')
.pipe(gulp.dest('dist/img'))
});
function watch() {
gulp.watch(paths.elm, ['elm']);
gulp.watch(paths.html, ['html']);
gulp.watch(paths.css, ['css']);
}
gulp.task('build', ['elm', 'html', 'css', 'font', 'img'])
gulp.task('default', ['build'], function() {
if (argv.serve) {
browserSync.init({
server: "./dist"
});
gulp.watch('./dist/index.html').on('change', browserSync.reload);
gulp.watch('./dist/**/*.js').on('change', browserSync.reload);
gulp.watch('./dist/**/*.css').on('change', browserSync.reload);
}
if (argv.watch) {
watch();
}
});