-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
54 lines (47 loc) · 1.48 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
const gulp = require('gulp'),
browserSync = require('browser-sync').create(),
sass = require('gulp-sass'),
postcss = require('gulp-postcss'),
sourcemaps = require('gulp-sourcemaps'),
autoprefixer = require('autoprefixer'),
babel = require('gulp-babel'),
minifyCSS = require('gulp-csso'),
htmlmin = require('gulp-htmlmin'),
uglify = require('gulp-uglify')
const path = {
sass: 'app/styles/sass/**/*.scss',
js: 'app/scripts/babel/**/*.js',
html: 'app/**/*.html'
}
gulp.task('serve', [ 'html', 'sass', 'js' ], () => {
browserSync.init({ server: './app' })
gulp.watch(path.sass, ['sass'])
gulp.watch(path.js, ['js-watch'])
gulp.watch('path.html', ['html']).on('change', browserSync.reload);
})
gulp.task('html', () => {
return gulp.src('path.html')
.pipe(htmlmin({collapseWhitespace: true}))
.pipe(gulp.dest('app/dist/index.html'))
})
gulp.task('sass', () => {
return gulp.src(path.sass)
.pipe(sourcemaps.init())
.pipe(postcss([ autoprefixer() ]))
.pipe(sass())
.pipe(minifyCSS())
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('app/dist/css'))
.pipe(browserSync.stream())
})
gulp.task('js', () => {
return gulp.src(path.js)
.pipe(babel())
.pipe(uglify())
.pipe(gulp.dest('app/dist/js'));
})
gulp.task('js-watch', ['js'], done => {
browserSync.reload()
done()
})
gulp.task('default', ['serve'])