-
Notifications
You must be signed in to change notification settings - Fork 61
/
gulpfile.js
86 lines (71 loc) · 1.96 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
/* requires */
var gulp = require('gulp'),
util = require('gulp-util'),
browserSync = require('browser-sync'),
cache = require('gulp-cached'),
fileinclude = require('gulp-file-include'),
rename = require('gulp-rename'),
concat = require('gulp-concat'),
filter = require('gulp-filter'),
rimraf = require('rimraf'),
autoprefixr = require('autoprefixer'),
nocomments = require('postcss-discard-comments'),
sass = require('gulp-sass'),
postcss = require('gulp-postcss'),
minifyCSS = require('gulp-minify-css');
/* paths */
var input = {
html: 'dev/example/**/*.html',
scss: 'dev/scss/**/*.scss',
images: 'dev/example/images/*'
},
output = {
dist: 'dist',
main: 'example',
css: 'example/css',
images: 'example/images'
};
gulp.task('default', ['build', 'server', 'watch']);
gulp.task('build', ['markup', 'styles', 'images']);
gulp.task('markup', function() {
gulp.src(input.html)
.pipe(fileinclude().on('error', util.log))
.pipe(cache('htmling'))
.pipe(filter(['*', '!dev/example/includes']))
.pipe(gulp.dest(output.main))
.pipe(browserSync.stream());
});
gulp.task('styles', function() {
gulp.src(input.scss)
.pipe(concat('awsm.scss'))
.pipe(sass().on('error', util.log))
.pipe(postcss([ autoprefixr({ browsers: [ "> 1%" ] }), nocomments() ]))
.pipe(gulp.dest(output.css))
.pipe(gulp.dest(output.dist))
.pipe(minifyCSS())
.pipe(rename('awsm.min.css'))
.pipe(gulp.dest(output.css))
.pipe(gulp.dest(output.dist))
.pipe(browserSync.stream());
});
gulp.task('images', function() {
gulp.src(input.images)
.pipe(gulp.dest(output.images))
.pipe(browserSync.stream());
});
gulp.task('server', function() {
browserSync.init({
server: output.main,
open: false,
browser: "browser",
reloadOnRestart: true
});
});
gulp.task('watch', function() {
gulp.watch(input.html, ['markup']);
gulp.watch(input.scss, ['styles']);
gulp.watch(input.images, ['images']);
});
gulp.task('clean', function(cb) {
rimraf(output.main, cb);
});