-
Notifications
You must be signed in to change notification settings - Fork 20
/
gulpfile.js
86 lines (77 loc) · 2.08 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
75
76
77
78
79
80
81
82
83
84
85
86
var gulp = require('gulp'),
sass = require('gulp-sass'),
concat = require("gulp-concat"),
merge = require('merge-stream'),
sourcemaps = require('gulp-sourcemaps'),
cleanCss = require('gulp-clean-css'),
rename = require('gulp-rename'),
postcss = require('gulp-postcss'),
autoprefixer = require('autoprefixer'),
expect = require('gulp-expect-file'),
uglify = require('gulp-uglify'),
del = require('del'),
browserSync = require("browser-sync").create();
gulp.task('styles', function() {
return gulp.src([
'src/_scss/*.scss'
])
.pipe(sourcemaps.init())
.pipe(sass().on('error', sass.logError))
.pipe(postcss([ autoprefixer({ browsers: [
'Chrome >= 35',
'Firefox >= 38',
'Edge >= 12',
'Explorer >= 10',
'iOS >= 8',
'Safari >= 8',
'Android 2.3',
'Android >= 4',
'Opera >= 12']})]))
.pipe(concat("modal-fx.css"))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('dist/css/'))
.pipe(cleanCss())
.pipe(rename({suffix: '.min'}))
.pipe(gulp.dest('dist/css/'))
.pipe(browserSync.stream());
});
function handleError (error) {
console.log(error.toString())
this.emit('end')
}
gulp.task("scripts", function() {
var files = [
"src/_js/**/*.js"
];
return gulp
.src(files)
.pipe(expect(files))
.on('error', handleError)
.pipe(concat("modal-fx.js"))
.pipe(gulp.dest("dist/js/"))
.pipe(uglify())
.pipe(rename({suffix: '.min'}))
.pipe(gulp.dest("dist/js/"))
.pipe(browserSync.stream());
});
gulp.task('watch', ['styles'], function() {
gulp.watch(['src/_scss/**/*.scss'], ['styles']);
gulp.watch(['src/_js/**/*.js'], ['scripts']);
});
gulp.task(
"live",["watch", "scripts", "styles"],
function() {
browserSync.init({
server: {
baseDir: "./"
}
});
gulp.watch("src/_scss/**/*.scss", ["watch"]);
gulp.watch("src/_js/**/*.js", ["watch"]);
gulp.watch("**/*.html").on("change", browserSync.reload);
});
gulp.task('clean', function() {
return del("dist");
});
gulp.task("default", ["styles", "scripts"], function() {
});