-
Notifications
You must be signed in to change notification settings - Fork 2
/
gulpfile.js
42 lines (38 loc) · 1.21 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
const gulp = require('gulp');
const sass = require('gulp-sass');
const concat = require('gulp-concat');
const babel = require('gulp-babel');
const autoprefixer = require('gulp-autoprefixer');
const browserSync = require('browser-sync').create();
const reload = browserSync.reload;
//a task to compile our sass
gulp.task('styles', () => {
return gulp.src('./dev/styles/**/*.scss')
.pipe(sass().on('error', sass.logError))
.pipe(autoprefixer('last 2 version', 'safari 5', 'ie 8', 'ie 9', 'opera 12.1'))
.pipe(concat('style.css'))
.pipe(gulp.dest('./public/styles'))
.pipe(reload({stream: true}));
});
//a task to compile our javascript
gulp.task('scripts', () => {
return gulp.src('./dev/scripts/main.js')
.pipe(babel({
presets: ['es2015']
}))
.pipe(gulp.dest('./public/scripts'))
.pipe(reload({stream: true}));
});
// a task to watch all other tasks
gulp.task('watch', function() {
gulp.watch('./dev/scripts/**/*.js', ['scripts']);
gulp.watch('./dev/styles/**/*.scss', ['styles']);
gulp.watch('*.html', reload);
});
//browser sync
gulp.task('browser-sync', () => {
browserSync.init({
server: '.'
})
});
gulp.task('default', ['styles', 'scripts', 'watch', 'browser-sync'])