-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
74 lines (66 loc) · 2.04 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
70
71
72
73
74
var gulp = require('gulp'),
autoprefixer = require('gulp-autoprefixer'),
concat = require('gulp-concat'),
imageMin = require('gulp-imagemin'),
minifyCSS = require('gulp-minify-css'),
notify = require('gulp-notify'),
plumber = require('gulp-plumber'),
sass = require('gulp-sass'),
sourcemaps = require('gulp-sourcemaps'),
uglify = require('gulp-uglify'),
babel = require('gulp-babel'),
browserSync = require('browser-sync'),
reload = browserSync.reload;
gulp.task('bs', function() {
browserSync.init({
// if running on windows, change this to http://localhost
server: './'
});
});
gulp.task('styles', function() {
return gulp.src('src/sass/**/*.scss')
.pipe(plumber({
errorHandler: notify.onError("Error: <%= error.message %>")
}))
.pipe(sourcemaps.init())
.pipe(sass())
.pipe(minifyCSS())
.pipe(concat('styles.css'))
.pipe(autoprefixer('last 5 version', 'safari 5', 'ie 8', 'ie 9', 'opera 12.1'))
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('dist/css'))
.pipe(reload({stream:true}));
});
gulp.task('scripts', function() {
return gulp.src('src/js/*.js')
.pipe(plumber({
errorHandler: notify.onError("Error: <%= error.message %>")
}))
.pipe(babel({
presets: ['env']
}))
.pipe(uglify())
.pipe(concat('scripts.min.js'))
.pipe(gulp.dest('dist/js'))
.pipe(reload({stream:true}));
});
gulp.task('images', function() {
return gulp.src('src/images/**/*')
.pipe(imageMin())
.pipe(gulp.dest('dist/images'));
});
gulp.task('fonts', function() {
return gulp.src('src/fonts/**/*')
.pipe(gulp.dest('dist/fonts'));
});
gulp.task('fontawesome-markers', function() {
return gulp.src('node_modules/fontawesome-markers/fontawesome-markers.min.js')
.pipe(gulp.dest('dist/js'));
});
// configure which files to watch and what tasks to use on file changes
gulp.task('watch', function() {
gulp.watch('src/sass/**/*.scss', ['styles']);
gulp.watch('src/js/**/*.js', ['scripts']);
gulp.watch('*.html', reload);
});
gulp.task('default', ['styles', 'scripts', 'images', 'fonts', 'fontawesome-markers', 'bs', 'watch']);