-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
117 lines (100 loc) · 2.78 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
// Include gulp
var gulp = require('gulp');
// Include Our Plugins
var sass = require('gulp-sass');
var haml = require('gulp-haml');
var rename = require('gulp-rename');
var connect = require('gulp-connect');
var plumber = require('gulp-plumber');
var notify = require("gulp-notify");
var livereload = require("gulp-livereload");
var autoprefixer = require("gulp-autoprefixer");
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var react = require('gulp-react');
//sounds: Basso, Blow, Bottle, Frog, Funk, Glass, Hero, Morse, Ping, Pop, Purr, Sosumi, Submarine, Tink
// File paths to various assets are defined here.
var PATHS = {
javascript: [
// "js/vendors/react.min.js",
// "js/vendors/react-dom.min.js",
// "js/vendors/babel.min.js",
"js/components.js"
]
};
// Compile Our Sass
gulp.task('sass', function() {
var onError = function(err) {
notify.onError({
title: "SASS",
message: "Compilation error!",
sound: "Funk"
})(err);
console.log(err);
this.emit('end');
};
livereload.listen();
return gulp.src('sass/main.sass')
.pipe(plumber({errorHandler: onError}))
.pipe(sass({outputStyle: 'compressed'}))
.pipe(rename('styles.min.css'))
.pipe(autoprefixer({
browsers: ['> 5%'],
cascade: false
}))
.pipe(gulp.dest('./css/'))
.pipe(livereload())
.pipe(notify({title: "SASS", message: "compilation [OK]"}))
});
gulp.task('haml', function() {
var onError = function(err) {
notify.onError({
title: "HAML",
message: "Compilation error!",
sound: "Funk"
})(err);
console.log(err);
this.emit('end');
};
livereload.listen();
return gulp.src('haml/**/*.haml')
.pipe(plumber({errorHandler: onError}))
.pipe(haml())
.pipe(gulp.dest('./'))
.pipe(livereload())
.pipe(notify({title: "HAML", message: "compilation [OK]"}))
});
gulp.task('react', function() {
var onError = function(err) {
notify.onError({
title: "REACT",
message: "Compilation error!",
sound: "Funk"
})(err);
console.log(err);
this.emit('end');
};
livereload.listen();
return gulp.src(PATHS.javascript)
.pipe(plumber({errorHandler: onError}))
.pipe(react())
.pipe(concat('all.min.js'))
.pipe(gulp.dest('./js/'))
.pipe(livereload())
.pipe(notify({title: "JS", message: "compilation [OK]"}))
});
//Creates a local server on port 8000
gulp.task('connect', function() {
connect.server({
name: 'local dev',
port: 8888,
livereload: true
});
});
// Default Task
gulp.task('default', ['sass', 'haml', 'react', 'connect'], function() {
// Watch Files For Changes
gulp.watch('sass/**/*.sass', ['sass']);
gulp.watch('haml/**/*.haml', ['haml']);
gulp.watch('js/**/*.js', ['react']);
});