-
Notifications
You must be signed in to change notification settings - Fork 0
/
_gulpfile.js
72 lines (63 loc) · 2.21 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
/*
* Copyright (c) 2015, Sarbborram Bandyopadhyay. All rights reserved.
* Copyrights licensed under the MIT License.
* See the accompanying LICENSE file for terms.
*/
var del = require('del');
var gulp = require('gulp');
var postcss = require('gulp-postcss');
var rename = require('gulp-rename');
var header = require('gulp-header');
var rtlcss = require('gulp-rtlcss');
var cssmin = require('gulp-minify-css');
var pkg = require('./package.json');
var banner = ['/*',
' * Copyright (c) <%= new Date().getFullYear() %>, <%= pkg.author %>. All rights reserved.',
' * Copyrights licensed under the <%= pkg.license %> License.',
' * See the accompanying LICENSE file for terms.',
' */',
'\n'
].join('\n');
gulp.task('clean', function () {
del(['dist/css/*.css'], function (error, deletedFiles) {
console.log('files deleted:', deletedFiles.join(', '));
});
});
gulp.task('postcss', function () {
var processors = [
require('postcss-import')(),
require('postcss-discard-comments'),
require('postcss-custom-properties')(),
require('postcss-mixins')(),
require('postcss-nested'),
require('postcss-calc')(),
require('postcss-media-minmax')(),
require('postcss-custom-media')(),
require('autoprefixer-core')({browsers: 'last 3 version'})
];
return gulp.src('./src/css/main.css')
.pipe(postcss(processors))
.pipe(rename('ltr.css'))
.pipe(gulp.dest('./dist/css'));
});
gulp.task('rtlcss', ['postcss'], function () {
return gulp.src('./dist/css/ltr.css')
.pipe(rtlcss())
.pipe(rename('rtl.css'))
.pipe(gulp.dest('./dist/css/'));
});
gulp.task('cssmin', ['postcss', 'rtlcss'], function() {
return gulp.src('./dist/css/*.css')
.pipe(cssmin())
.pipe(rename({suffix: '.min', extname: '.css'}))
.pipe(gulp.dest('./dist/css'));
});
gulp.task('banner', ['postcss', 'rtlcss', 'cssmin'], function () {
return gulp.src('./dist/css/*.css')
.pipe(header(banner, { pkg : pkg } ))
.pipe(gulp.dest('./dist/css/'));
});
gulp.task('watch', function() {
gulp.watch('src/css/**/*.css', ['clean', 'postcss', 'rtlcss', 'cssmin', 'banner']);
});
gulp.task('default', ['clean', 'postcss', 'rtlcss', 'cssmin', 'banner']);