-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
74 lines (66 loc) · 1.84 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
var gulp = require("gulp"),
del = require("del"),
browserify = require("browserify"),
source = require("vinyl-source-stream"),
buffer = require("vinyl-buffer"),
htmlmin = require("gulp-htmlmin"),
sass = require("gulp-sass");
gulp.task('sass', function () {
return gulp.src('./assets/css/*.scss')
.pipe(sass()).on('error', errorHandler)
.pipe(gulp.dest('./public/style'));
});
// gulp.task("fonts", function() {
// return gulp.src([
// "./node_modules/font-awesome/fonts/*",
// "./node_modules/roboto-fontface/fonts/*"
// ])
// .pipe(gulp.dest("./public/fonts"));
// });
gulp.task("clean", function(cb) {
return del(["public"], cb);
});
gulp.task("react", function() {
// return gulp.src("./assets/react/app.jsx")
// .pipe(browserify({
// 'transform': 'babelify',
// 'presets': ["es2015", "react"],
// 'require': [
// 'react',
// 'react-dom'
// ],
// debug: true
// }))
// .pipe(gulp.dest("./public/js/app.js"));
var bundler = browserify('assets/react/app.jsx');
return bundler
.transform('babelify', { presets: ['es2015', 'react'] })
.bundle()
.pipe(source('app.js'))
.pipe(buffer())
.pipe(gulp.dest("./public/js/"));
});
gulp.task('html', function () {
return gulp.src('./assets/html/*.html')
.pipe(htmlmin({
collapseWhitespace: true,
ignoreCustomFragments: [ /<%[\s\S]*?%>/, /<\?[\s\S]*?\?>/, /{{[\s\S]*?}}/ ]
})).on('error', errorHandler)
.pipe(gulp.dest('./public/'))
});
// Use while developing
gulp.task("default", ["clean"], function(){
gulp.start(
"sass",
"html",
// "fonts",
"react"
);
gulp.watch('./assets/html/*.html', ['html']);
gulp.watch('./assets/css/*.scss', ['sass']);
gulp.watch(['./assets/react/**/*.jsx','./assets/react/**/*.js'], ['react']);
});
function errorHandler (error) {
console.log(error.toString());
this.emit('end');
}