-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
executable file
·69 lines (61 loc) · 1.67 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
const gulp = require('gulp');
const sass = require('gulp-sass');
const autoprefixer = require('gulp-autoprefixer');
const uglify = require('gulp-uglify');
const concat = require('gulp-concat');
const babel = require('gulp-babel');
const imagemin = require('gulp-imagemin');
const pngquant = require('imagemin-pngquant');
const webpack = require('webpack-stream');
const watch = require('gulp-watch');
const browserSync = require('browser-sync');
const reload = browserSync.reload;
gulp.task('browser-sync', function() {
browserSync({
server: './public'
});
});
gulp.task('default', ['styles', 'scripts', 'browser-sync'], () => {
gulp.watch('./src/sass/**/*', ['styles']).on('change', reload);
gulp.watch('./src/**/*', ['scripts']).on('change', reload);
gulp.watch('./public/*.html')
.on('change', reload);
});
gulp.task('styles', () => {
gulp.src('src/sass/**/*.scss')
.pipe(
sass({
outputStyle: 'compressed',
})
.on('error', sass.logError))
.pipe(autoprefixer({
browsers: ['last 2 versions'],
}))
.pipe(gulp.dest('./public/css'))
// .pipe(browserSync.stream());
});
// Regular JavaScripts
gulp.task('scripts', () => {
gulp.src('src/js/**/*.js')
.pipe(babel({
presets: ['es2015'],
}))
.pipe(concat('all.js'))
.pipe(uglify())
.pipe(gulp.dest('./public/js'));
});
// Images
gulp.task('images', () =>
gulp.src('src/img/*')
.pipe(imagemin({
progressive: true,
use: [pngquant()],
}))
.pipe(gulp.dest('img'))
);
// For React
// gulp.task('react', () => {
// gulp.src('client/')
// .pipe(webpack(require('./webpack.config.js')))
// .pipe(gulp.dest('client/public/js'));
// });