-
Notifications
You must be signed in to change notification settings - Fork 55
/
gulpfile.js
146 lines (110 loc) · 3.02 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
/*eslint-env node */
var gulp = require('gulp');
var gutil = require('gulp-util');
var connect = require('gulp-connect');
gulp.task('connect', function() {
connect.server({
root: './',
port: 3000,
livereload: true
});
});
/* *************
CSS
************* */
var sass = require('gulp-sass');
var postcss = require('gulp-postcss');
var scss = require('postcss-scss');
var autoprefixer = require('autoprefixer');
var postcssProcessors = [
autoprefixer({
browsers: [
'Explorer >= 11',
'last 2 Explorer versions',
'last 2 ExplorerMobile versions',
'last 2 Edge versions',
'last 2 Firefox versions',
'last 2 FirefoxAndroid versions',
'last 2 Chrome versions',
'last 2 ChromeAndroid versions',
'last 3 Safari versions',
'last 3 iOS versions',
'last 2 Opera versions',
'last 2 OperaMini versions',
'last 2 OperaMobile versions',
'last 2 Android versions',
'last 2 BlackBerry versions'
]
})
];
var sassMainFile = 'sass/main.scss';
var sassFiles = 'sass/**/*.scss';
gulp.task('css', function() {
gulp.src(sassMainFile)
.pipe(
postcss(postcssProcessors, { syntax: scss })
)
.pipe(
sass({ outputStyle: 'compressed' })
.on('error', gutil.log)
)
.pipe(gulp.dest('css'))
.pipe(connect.reload());
});
// /* *************
// HTML
// ************* */
// var minifyHTML = require('gulp-minify-html');
var htmlFiles = ['*.html'];
// gulp.task('html', function() {
// gulp.src('src/index.html')
// .pipe(minifyHTML({ empty: true }))
// .pipe(gulp.dest('public'));
// gulp.src('src/views/*.html')
// .pipe(minifyHTML({ empty: true }))
// .pipe(gulp.dest('public/views'));
// gulp.src('src/views/inc/*.html')
// .pipe(minifyHTML({ empty: true }))
// .pipe(gulp.dest('public/views/inc'));
// gulp.src('src/views/directives/*.html')
// .pipe(minifyHTML({ empty: true }))
// .pipe(gulp.dest('public/views/directives'));
// });
gulp.task('html', function() {
gulp.src('*.html')
.pipe(connect.reload());
});
gulp.task('js', function() {
gulp.src('js/*.js')
.pipe(connect.reload());
});
/* *************
WATCH
************* */
gulp.task('watch', function() {
gulp.watch(sassFiles, ['css']);
gulp.watch('*.js', ['js']);
gulp.watch(htmlFiles, ['html']);
});
/* *************
DEFAULT
************* */
gulp.task('default', ['connect', 'css', 'watch']);
/* *************
SVG
************* */
var svgSprite = require('gulp-svg-sprite');
var svgConfig = {
mode: {
css: {
render: {
css: true
}
}
}
};
gulp.task('svg', function() {
gulp.src('**/*.svg', { cwd: 'images/icons/source' })
.pipe(svgSprite(svgConfig))
.pipe(gulp.dest('images/icons'));
});