-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
43 lines (36 loc) · 1.05 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
const gulp = require('gulp');
const cssnano = require('gulp-cssnano');
const babel = require('gulp-babel');
const useref = require('gulp-useref');
const uglify = require('gulp-uglify');
const gulpIf = require('gulp-if');
const htmlmin = require('gulp-htmlmin');
const browserSync = require('browser-sync').create();
const paths = {
scripts: './public/scrips/*.js',
styles: './public/styles/*.css',
html: './public/index.html',
all: './public/**/*.*'
};
gulp.task('browser-sync', () => {
browserSync.init({
proxy: 'localhost:2579',
port: 3469,
open: false
});
gulp.watch(paths.all, () => {
browserSync.reload();
});
});
const babelCFG = {
presets: ['es2015']
};
gulp.task('build', () => {
return gulp.src('./public/index.html')
.pipe(useref())
.pipe(gulpIf('*.js', babel(babelCFG)))
.pipe(gulpIf('*.js', uglify()))
.pipe(gulpIf('*.css', cssnano()))
.pipe(gulpIf('*.html', htmlmin({ collapseWhitespace: true })))
.pipe(gulp.dest('./build'));
});