This repository has been archived by the owner on Dec 2, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgulpfile.js
79 lines (71 loc) · 1.88 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
var babelify = require('babelify');
var browserify = require('browserify');
var buffer = require('vinyl-buffer');
var cssnext = require('gulp-cssnext');
var eslint = require('gulp-eslint');
var gulp = require('gulp');
var minifyHTML = require('gulp-minify-html');
var rename = require('gulp-rename');
var source = require('vinyl-source-stream');
var uglify = require('gulp-uglify');
var config = {
babelify: {
optional: [
'es7.asyncFunctions',
'es7.functionBind',
'es7.objectRestSpread',
'es7.trailingFunctionCommas',
'runtime'
]
},
browserify: {
fileName: 'app.js',
extensions: ['.jsx']
},
cssnext: {
compress: true
}
}
var paths = {
src: {
eslint: './source/es6/**/*.jsx',
js : './source/es6/app.jsx',
css : './source/css/main.css',
html : './source/html/**/*.html'
},
build: {
js : './assets/js/',
css : './assets/css/',
html : './'
}
}
gulp.task('build:js', function () {
return browserify({
entries: paths.src.js,
debug: false,
extensions: config.browserify.extensions,
transform: [babelify.configure(config.babelify)]
}).bundle()
.pipe(source(config.browserify.fileName))
.pipe(buffer())
//.pipe(uglify())
.pipe(gulp.dest(paths.build.js))
});
gulp.task('build:css', function () {
gulp.src(paths.src.css)
.pipe(cssnext(config.cssnext))
.pipe(rename('style.css'))
.pipe(gulp.dest(paths.build.css))
});
gulp.task('build:html', function () {
gulp.src(paths.src.html)
.pipe(minifyHTML())
.pipe(gulp.dest(paths.build.html))
});
gulp.task('watch', function () {
gulp.watch([paths.src.eslint], ['build:js']);
gulp.watch([paths.src.css], ['build:css'])
gulp.watch([paths.src.html], ['build:html', 'build:css']);
});
gulp.task('build', ['build:html', 'build:css', 'build:js']);
gulp.task('default', ['build']);