-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
69 lines (57 loc) · 1.64 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
const gulp = require('gulp');
const concat = require('gulp-concat');
const connect = require('gulp-connect');
const elm = require('gulp-elm');
const inject = require('gulp-inject');
const plumber = require('gulp-plumber');
const sass = require('gulp-sass');
const del = require('del');
const paths = {
dest: 'dist',
index: 'dist/*.html',
elm: 'src/elm/**/*.elm',
sass: 'src/scss/**/*.scss',
static: ['src/**/*.html', 'src/**/*.js'],
nodeModules: 'node_modules'
};
gulp.task('clean', () => del(['dist']));
gulp.task('elm-init', elm.init);
gulp.task('elm', ['elm-init'], () => gulp.src(paths.elm)
.pipe(plumber())
.pipe(elm())
.pipe(gulp.dest('dist/js'))
.pipe(connect.reload())
);
gulp.task('static', ['elm'], () => gulp.src(paths.static)
.pipe(plumber())
.pipe(gulp.dest(paths.dest)));
gulp.task('build', ['static', 'sass'], () => {
const target = gulp.src(paths.index);
const sources = gulp.src(['dist/**/*.js', 'dist/**/*.css'], { read: false });
return target.pipe(inject(sources, { relative: true }))
.pipe(gulp.dest(paths.dest))
.pipe(connect.reload());
});
gulp.task('serve', ['build'], () => {
connect.server({
root: './dist',
livereload: true
});
});
gulp.task('sass', () => {
return gulp.src(paths.sass)
.pipe(plumber())
.pipe(sass({
includePaths: [paths.nodeModules]
}))
.pipe(concat('styles.css'))
.pipe(gulp.dest('dist'))
.pipe(connect.reload());
});
gulp.task('watch', () => {
gulp.watch(paths.sass, ['sass']);
gulp.watch(paths.elm, ['elm']);
gulp.watch(paths.static, ['build']);
});
gulp.task('default', ['serve', 'watch']);
gulp.task('build:prod', ['clean', 'build']);