This repository has been archived by the owner on Mar 1, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
63 lines (53 loc) · 1.94 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
var gulp = require('gulp');
var rename = require('gulp-rename');
var sass = require('gulp-sass');
var postcss = require('gulp-postcss');
var autoprefixer = require('autoprefixer');
var minifyCSS = require('gulp-minify-css');
var sourcemaps = require('gulp-sourcemaps');
gulp.task('sass', function () {
var processors = [
autoprefixer({browsers: ['last 30 versions', 'ie 9']})
];
return gulp.src('./src/**/*.scss')
.pipe(sourcemaps.init())
.pipe(sass().on('error', sass.logError))
.pipe(postcss(processors))
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('./dist'));
});
gulp.task('default',['sass'], function() {
gulp.src('./dist/cleanSS.css')
.pipe(minifyCSS())
.pipe(rename('cleanSS.min.css'))
.pipe(gulp.dest('./dist'));
gulp.src('./dist/cleanSS-fonts.css')
.pipe(minifyCSS())
.pipe(rename('cleanSS-fonts.min.css'))
.pipe(gulp.dest('./dist'));
});
gulp.task('watch', function () {
gulp.watch('./src/**/*.scss', ['default']);
});
// Font Tasks
var cssfont64 = require('gulp-simplefont64');
var del = require('del');
var concat = require('gulp-concat');
// Take all fonts from the ./fonts/ folder and generate a temporary folder with all base64 css
gulp.task('base64convert', function () {
return gulp.src(['./fonts/*.woff', './fonts/*.ttf'])
.pipe(cssfont64())
.pipe(gulp.dest('./fonts/temp'));
});
// Concatenate all the CSS Files in the temporary folder and move it to the src folder
gulp.task('base64concat',['base64convert'], function () {
return gulp.src('./fonts/temp/*.css')
.pipe(concat('_fonts.scss'))
.pipe(gulp.dest('src'));
});
// after all of it is done, remove the temporary folder!
gulp.task('base64css',['base64concat'], function () {
del('./fonts/temp').then(function (paths) {
console.log('Deleted files/folders:\n', paths.join('\n'));
});
});