-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gulpfile.js
117 lines (98 loc) · 3.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
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
var gulp = require('gulp'),
/** Sass - Css **/
sass = require('gulp-sass'),
plumber = require('gulp-plumber'),
nano = require('gulp-cssnano'),
autoprefixer = require('gulp-autoprefixer'),
sourcemaps = require('gulp-sourcemaps'),
/** javascript **/
concat = require('gulp-concat'),
uglify = require('gulp-uglify'),
/** Images **/
imagemin = require('gulp-imagemin'),
/** Development **/
del = require('del'),
webstandards = require('gulp-webstandards'),
gulpif = require('gulp-if');
/** Check to see if project is in development **/
var inDevelopment = false;
/** Theme name **/
var theme = 'blush';
/** Path to Theme **/
var output = '../cosmetics/wp-content/themes/' + theme + '/';
/** Development Paths **/
var Paths = {
'bower' : 'bower_components'
};
/** An Array of Sass file paths to include **/
var SassArray = [];
var JavascriptArray = [
Paths.bower + '/jquery/dist/jquery.js',
Paths.bower + '/luna/Framework/js/luna.js',
Paths.bower + '/fastclick/lib/fastclick.js',
Paths.bower + '/jquery-slimscroll/jquery.slimscroll.js',
Paths.bower + '/slabText/js/jquery.slabtext.js',
Paths.bower + '/Waves/dist/waves.js',
theme + '/js/blush.js'
];
var FontArray = [
Paths.bower + '/lunacon/lunacon/fonts/**/*.{eot,svg,ttf,woff}'
];
/** Sass Builder **/
gulp.task('sass', function(){
// return gulp.src(theme + '/sass/style.{sass,scss}')
return gulp.src(theme + '/sass/**/*.{sass,scss}')
// return gulp.src(theme + '/sass/style-black-white.{sass,scss}')
.pipe(plumber())
.pipe(sourcemaps.init())
.pipe(sass({
sourceComments: true,
includePaths: SassArray,
}).on('error', sass.logError))
.pipe(autoprefixer({
browsers: ['last 5 versions'],
cascade: false
}))
.pipe(gulpif(!inDevelopment, nano()))
.pipe(sourcemaps.write('/'))
.pipe(gulp.dest(output));
});
/** Html Builder **/
gulp.task('html', function(){
return gulp.src(theme + '/html/**/*.php')
.pipe(gulp.dest(output));
});
/** Javascript Builder **/
gulp.task('javasript', function(){
return gulp.src(JavascriptArray)
.pipe(gulpif(!inDevelopment, uglify()))
.pipe(concat('app.js'))
.pipe(gulp.dest(output + '/js'));
});
/** Image Minifacation**/
gulp.task('image', function(){
return gulp.src(theme + '/img/**/*.{jpg,jpeg,png,gif,webp}')
.pipe(imagemin())
.pipe(gulp.dest(output + '/img'));
});
/** Copy font to Output directory**/
gulp.task('fonts', function(){
gulp.src(FontArray)
.pipe(gulp.dest(output + '/fonts'));
});
/** Gulp Watcher - Watch for changes when saves **/
gulp.task('watch', function(){
gulp.watch(theme + '/sass/**/*.{sass,scss}', ['sass']);
gulp.watch(theme + '/html/**/*.php', ['html']);
gulp.watch(theme + '/js/**/*.js', ['javasript']);
gulp.watch(theme + '/img/**/*.{jpg,jpeg,png,gif,webp}', ['image']);
});
/** Remove fonts from build folder **/
gulp .task('clean', function(){
del([output + '/fonts/**/*'], {force: true});
});
gulp.task('web', function () {
return gulp.src(output + '*.css')
.pipe(webstandards());
});
gulp.task('default', ['watch','sass', 'html', 'image', 'javasript', 'fonts']);