-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
55 lines (49 loc) · 1.35 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
const gulp = require('gulp');
const browserSync = require('browser-sync').create();
const babel = require('gulp-babel');
const browserify = require('gulp-browserify');
const uglify = require('gulp-uglify');
// Sass/CSS stuff
const sass = require('gulp-sass');
const prefix = require('gulp-autoprefixer');
const minifycss = require('gulp-minify-css');
// compile all Sass
gulp.task('styles', function (){
return gulp.src('./styles/sass/**/*.scss')
.pipe(sass().on('error', sass.logError))
.pipe(gulp.dest('./dist/css'))
.pipe(browserSync.stream());
});
// process JS files and return the stream.
gulp.task('js', function() {
return (
gulp
.src('js/*js')
.pipe(
babel({
presets: ['env'],
})
)
.pipe(browserify())
.pipe(uglify())
.pipe(gulp.dest('dist/js'))
);
});
// create a task that ensures the `js` task is complete before
// reloading browsers
gulp.task('js-watch', ['js'], function(done) {
browserSync.reload();
done();
});
// use default task to launch Browsersync and watch JS files
gulp.task('default', ['js'], function() {
// Serve files from the root of this project
browserSync.init({
server: {
baseDir: './',
},
});
gulp.watch('js/*.js', ['js-watch']);
gulp.watch('./styles/sass/*.scss', ['styles']);
gulp.watch('index.html', ['styles']);
});