-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
76 lines (66 loc) · 1.65 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
71
72
73
74
75
76
var gulp = require('gulp');
var babel = require('gulp-babel');
var gutil = require('gulp-util');
var sass = require('gulp-sass');
var spawn = require('child_process').spawn;
gulp.task('js', function () {
return gulp.src([
'src/app/*.js', 'src/app/**/*.js'
])
.pipe(babel({
sourceMaps: 'inline',
presets: ['es2015'],
plugins: ['transform-es2015-modules-amd']
}))
.pipe(gulp.dest('dist/app'));
});
gulp.task('elm', function() {
// Finally execute your script below - here "ls -lA"
var child = spawn("elm-make", [
"src/app/Search.elm",
"--output=dist/app/Search.js"
], {cwd: process.cwd()}),
stdout = '',
stderr = '';
child.stdout.setEncoding('utf8');
child.stdout.on('data', function (data) {
stdout += data;
gutil.log(data);
});
child.stderr.setEncoding('utf8');
child.stderr.on('data', function (data) {
stderr += data;
gutil.log(gutil.colors.red(data));
gutil.beep();
});
child.on('close', function(code) {
gutil.log("Elm files compiled");
});
});
gulp.task('sass', function () {
gulp.src('src/styles/*.scss')
.pipe(sass().on('error', sass.logError))
.pipe(gulp.dest('dist/styles'));
});
gulp.task('copy', function() {
return gulp.src([
'src/dojoConfig.js',
'src/index.html'
])
.pipe(gulp.dest('dist'));
});
gulp.task('watch', function(){
gulp.watch([
'src/app/*.elm'
], ['elm']);
gulp.watch([
'src/styles/*.scss'
], ['sass']);
gulp.watch([
'src/*.js', 'src/**/*.js', 'src/**/**/*.js'
], ['js']);
gulp.watch([
'src/dojoConfig.js', 'src/index.html'
], ['copy']);
});
gulp.task('default', ['js', 'elm', 'sass', 'copy']);