-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgulpfile.js
More file actions
88 lines (76 loc) · 2.93 KB
/
gulpfile.js
File metadata and controls
88 lines (76 loc) · 2.93 KB
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
var gulp = require('gulp'),
sass = require('gulp-ruby-sass'),
autoprefixer = require('gulp-autoprefixer'),
concat = require('gulp-concat'),
notify = require('gulp-notify'),
del = require('del'),
gutil = require('gulp-util'),
rename = require('gulp-rename'),
minifycss = require('gulp-minify-css'),
runSequence = require('run-sequence');
var config = {
srcPath:'./assets/',
bowerPath: './bower_components/',
mainPath: './',
libPath: 'lib/',
assetPath: 'assets/',
cssPath: 'css/',
jsPath: 'js/',
imgPath: 'img/'
};
gulp.task('Styles.clean', function (callback) {
return del(config.mainPath + config.assetPath + config.cssPath + '*.*', callback);
});
gulp.task('Styles.scss', function () {
return sass(config.srcPath + 'scss/main.scss')
.on('error', function (error) {
var lineNumber = (error.lineNumber) ? 'LINE ' + error.lineNumber + ' -- ' : '';
notify({
title: 'Task Failed [' + error.plugin + ']',
message: lineNumber + 'See console.',
sound: 'Sosumi'
}).write(error);
gutil.beep();
var report = '';
var chalk = gutil.colors.white.bgRed;
report += chalk('TASK:') + ' [' + error.plugin + ']\n';
report += chalk('PROB:') + ' ' + error.message + '\n';
if (error.lineNumber) {
report += chalk('LINE:') + ' ' + error.lineNumber + '\n';
}
if (error.fileName) {
report += chalk('FILE:') + ' ' + error.fileName + '\n';
}
console.error(report);
this.emit('end');
})
.pipe(autoprefixer('last 2 versions', 'safari 5', 'ie 8', 'ie 9'))
.pipe(gulp.dest(config.mainPath + config.assetPath + config.cssPath));
});
gulp.task('Styles.plaincss', function () {
return gulp.src([config.bowerPath + 'normalize-css/*.css',config.bowerPath + 'animate.css/animate.min.css', 'src/assets/css/*.css'])
.pipe(gulp.dest(config.mainPath + config.assetPath + config.cssPath));
});
gulp.task('Styles.minifycss', function () {
return gulp.src([config.mainPath + config.assetPath + config.cssPath + 'normalize.css', config.mainPath + config.assetPath + config.cssPath + 'animate.min.css' , config.mainPath + config.assetPath + config.cssPath + 'main.css'])
.pipe(concat('style.css'))
.pipe(rename({suffix: '.min'}))
.pipe(minifycss())
.pipe(gulp.dest(config.mainPath + config.assetPath + config.cssPath))
});
gulp.task('Styles', function (callback) {
runSequence(
'Styles.clean',
'Styles.scss',
'Styles.plaincss',
'Styles.minifycss',
callback);
});
gulp.task('compress', function () {
return gulp.src('*')
.pipe(zip('archive.zip'))
.pipe(gulp.dest('dist'));
});
gulp.task('Watch', function () {
gulp.watch('assets/scss/**/*.scss', ['Styles']);
});