-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
66 lines (57 loc) · 1.75 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
'use strict';
const gulp = require('gulp');
const connect = require('gulp-connect');
const htmlmin = require('gulp-htmlmin');
const sass = require('gulp-ruby-sass');
const autoprefixer = require('gulp-autoprefixer');
const browserify = require('browserify');
const babelify = require('babelify');
const source = require('vinyl-source-stream');
const streamify = require('gulp-streamify');
const uglify = require('gulp-uglify');
const PATH = './app/';
const DIST = './dist/';
gulp.task('html', () => {
gulp.src(PATH + '*.html')
.pipe(htmlmin({collapseWhitespace: true}))
.pipe(gulp.dest(DIST))
.pipe(connect.reload());
});
gulp.task('css', () => {
sass(PATH + 'sass/*.scss', {style: 'compressed'})
.pipe(autoprefixer({
browsers: ['last 2 versions'],
cascade: false
}))
.pipe(gulp.dest(DIST + 'css/'));
});
gulp.task('js', () => {
browserify(PATH + 'js/Start.js', {debug: true})
.transform(babelify, {
presets: ['es2015', 'react']
}).bundle()
.pipe(source('index.js'))
.pipe(gulp.dest(DIST + 'js/'))
.pipe(connect.reload());
});
gulp.task('js-build', () => {
browserify(PATH + 'js/Start.js', {debug: false})
.transform(babelify, {
presets: ['es2015', 'react']
}).bundle()
.pipe(source('index.js'))
.pipe(streamify(uglify()))
.pipe(gulp.dest(DIST + 'js/'));
});
gulp.task('watch', () => {
gulp.watch(PATH +'*.html', ['html']);
gulp.watch(PATH +'js/**/*.js', ['js']);
});
gulp.task('connect', () => {
connect.server({
root: DIST,
livereload: true
});
});
gulp.task('default', ['html', 'css', 'js', 'watch', 'connect']);
gulp.task('build', ['html', 'css', 'js-build']);