-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathgulpfile.js
70 lines (64 loc) · 1.86 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
var gulp = require('gulp');
var sass = require('gulp-sass');
var browserSync = require('browser-sync').create();
var header = require('gulp-header');
var cleanCSS = require('gulp-clean-css');
var autoprefixer = require('gulp-autoprefixer');
var rename = require("gulp-rename");
var pkg = require('./package.json');
// Set the banner content
var banner = ['/*!\n',
' * <%= pkg.title %> v<%= pkg.version %> (<%= pkg.homepage %>)\n',
' * Copyright 2018-' + (new Date()).getFullYear(), ' <%= pkg.author %>\n',
' * Licensed under <%= pkg.license %> (https://github.com/techx/<%= pkg.name %>/blob/master/LICENSE)\n',
' */\n',
''
].join('');
// Compiles SCSS files from /scss into /css
gulp.task('sass', function() {
return gulp.src(['scss/styles.scss', 'scss/animation.scss'])
.pipe(sass())
.pipe(header(banner, {
pkg: pkg
}))
.pipe(gulp.dest('css'))
.pipe(browserSync.reload({
stream: true
}))
});
// Minify compiled CSS
gulp.task('minify-css', ['sass'], function() {
return gulp.src(['css/styles.css', 'css/animation.css'])
.pipe(autoprefixer({
browsers: ['last 5 versions'],
cascade: false
}))
.pipe(cleanCSS({
compatibility: 'ie8'
}))
.pipe(rename({
suffix: '.min'
}))
.pipe(gulp.dest('css'))
.pipe(browserSync.reload({
stream: true
}))
});
// Default task
gulp.task('default', ['sass', 'animation-sass', 'minify-css']);
// Configure the browserSync task
gulp.task('browserSync', function() {
browserSync.init({
server: {
baseDir: '.'
},
})
})
// Dev task with browserSync
gulp.task('dev', ['browserSync', 'sass', 'minify-css'], function() {
gulp.watch('scss/*.scss', ['sass']);
gulp.watch('css/*.css', ['minify-css']);
// Reloads the browser whenever HTML files change
gulp.watch('*.html', browserSync.reload);
gulp.watch('js/*.js', browserSync.reload);
});