-
Notifications
You must be signed in to change notification settings - Fork 3
/
gulpfile.js
54 lines (49 loc) · 1.52 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
var gulp = require('gulp'),
sass = require('gulp-sass'),
browserSync = require('browser-sync').create(),
joinPaths = require('path').join,
rename = require('gulp-rename'),
minifyCss = require('gulp-minify-css'),
uglify = require('gulp-uglify'),
imagemin = require('gulp-imagemin'),
autoprefixer = require('gulp-autoprefixer');
var paths = {
entry: 'index.html',
scss: './scss',
js: './js',
img: './img',
bower: './bower_components',
dist: './dist'
}
gulp.task('scss', function() {
gulp.src(joinPaths(paths.scss, 'style.scss'))
.pipe(sass({
includePaths: [
paths.scss,
joinPaths(paths.bower, 'normalize-css')
]
}).on('error', sass.logError))
.pipe(autoprefixer({ browsers: ['last 2 versions'] }))
.pipe(minifyCss())
.pipe(rename('style.min.css'))
.pipe(gulp.dest(joinPaths(paths.dist, 'css')));
});
gulp.task('compressJs', function () {
gulp.src(joinPaths(paths.js, 'scripts.js'))
.pipe(uglify())
.pipe(rename('scripts.min.js'))
.pipe(gulp.dest(joinPaths(paths.dist, 'js')));
});
gulp.task('compressImages', function () {
gulp.src(joinPaths(paths.img, '/*'))
.pipe(imagemin())
.pipe(gulp.dest(joinPaths(paths.dist, 'img')));
});
gulp.task('default', ['scss', 'compressJs', 'compressImages'], function() {
browserSync.init({ server: './' });
gulp.watch(joinPaths(paths.scss, '**/*.scss'), ['scss']);
gulp.watch([
paths.entry,
joinPaths(paths.dist, '**/*.*')
]).on('change', browserSync.reload);
});