-
Notifications
You must be signed in to change notification settings - Fork 9
/
gulpfile.js
46 lines (40 loc) · 1.15 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
const gulp = require('gulp');
const sass = require('gulp-sass');
const minifyHTML = require('gulp-minify-html');
const browserify = require('browserify');
const babelify = require('babelify');
const source = require('vinyl-source-stream');
const browserSync = require('browser-sync');
const minifyjs = require('gulp-uglify');
const buffer = require('vinyl-buffer');
gulp.task('js', () => {
browserify('src/js/app.jsx')
.transform(babelify, {presets: ["es2015", "react"]})
.bundle()
.pipe(source('bundle.js'))
.pipe(buffer())
.pipe(minifyjs())
.pipe(gulp.dest('dist'));
});
gulp.task('minify-html', () => {
return gulp.src('src/index.html')
.pipe(minifyHTML())
.pipe(gulp.dest('./dist/'));
});
gulp.task('sass', () => {
gulp.src('src/styles/styles.scss')
.pipe(sass({includePaths: ['scss']}))
.pipe(gulp.dest('./dist'));
});
gulp.task('browser-sync', () => {
browserSync.init(["src/**/*.*"], {
server: {
baseDir: "./dist"
}
});
});
gulp.task('default', ['minify-html', 'sass', 'js'], () => {
gulp.watch("src/styles/*.scss", ['sass']);
gulp.watch('src/**/*.jsx', ['js']);
gulp.watch('src/*.html', ['minify-html']);
});