-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
164 lines (144 loc) · 4.15 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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
//gulp plugins
var gulp = require('gulp');
var browserSync = require('browser-sync').create();
// header provides $switcher variable to scss to add or remove switcher styles (demo and production versions)
var header = require('gulp-header');
var sass = require('gulp-sass');
var sourcemaps = require('gulp-sourcemaps');
//postCss
var postcss = require('gulp-postcss');
var autoprefixer= require('autoprefixer');
var flexbugs = require('postcss-flexbugs-fixes');
var stylefmt = require('stylefmt');
//js concat
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
//template scripts
var scripts = [
//jQuery not need in WP
//libs
// 'js/vendor/jquery-1.12.4.min.js',
// 'js/vendor/jquery-migrate-3.0.0.min.js',
'js/vendor/jquery-3.3.1.min.js',
// 'js/vendor/popper.min.js',
'js/vendor/bootstrap.bundle.js',
// //no npm
'js/vendor/affix.js',
'js/vendor/jquery.appear.js',
'js/vendor/jquery.cookie.js',
//menu
//no npm
'js/vendor/jquery.easing.1.3.js',
//no npm
'js/vendor/jquery.hoverIntent.js',
'js/vendor/superfish.js',
// //elements
'js/vendor/bootstrap-progressbar.min.js',
'js/vendor/jquery.countdown.min.js',
'js/vendor/jquery.countTo.js',
'js/vendor/jquery.easypiechart.min.js',
//
// //local scrolling
'js/vendor/jquery.scrollbar.min.js',
//https://github.com/flesler/jquery.localScroll
'js/vendor/jquery.localScroll.min.js',
//https://github.com/flesler/jquery.scrollTo
'js/vendor/jquery.scrollTo.min.js',
'js/vendor/jquery.ui.totop.js',
// //images-sliders
'js/vendor/jquery.parallax-1.1.3.js',
//prettyPhoto removed - not support jQuery v3 even with migration plugin
// 'js/vendor/jquery.prettyPhoto.js',
'js/vendor/isotope.pkgd.min.js',
'js/vendor/jquery.flexslider-min.js',
'js/vendor/owl.carousel.min.js',
//new photoswipe gallery
'js/vendor/photoswipe.js',
'js/vendor/photoswipe-ui-default.min.js',
//social
'js/vendor/jflickrfeed.min.js',
'js/vendor/spectragram.min.js',
'twitter/jquery.tweet.js',
];
//dependencies from node_modules
var vendorScripts = [
//JS files
'node_modules/jquery/dist/jquery.min.js',
'node_modules/bootstrap/dist/js/bootstrap.min.js',
//css
'node_modules/bootstrap/dist/css/bootstrap.min.css',
];
// Static Server + watching scss/html files
gulp.task('serve', function() {
browserSync.init({
server: {
baseDir: "./"
}
});
gulp.watch("./scss/**/*.scss", ['sass']);
gulp.watch("./scss_bootstrap/**/*.scss", ['sassBootstrap']);
//js and HTML files to reload on save
gulp.watch([
"./*.html",
"js/*.js",
]).on('change', browserSync.reload);
});
// Compile sass for production - no swithcer styles, no sourcemaps
gulp.task('sass', function() {
return gulp.src("./scss/**/*.scss")
.pipe(sourcemaps.init())
.pipe(header('$switcher: false;\n'))
// outputStyle
// Type: String Default: nested Values: nested, expanded, compact, compressed
.pipe(sass({outputStyle: 'expanded'}).on('error', sass.logError))
.pipe(postcss([ autoprefixer({
"browsers": [
"> 0.1%"
]
}), flexbugs(), stylefmt(
{
"extends": "stylelint-config-suitcss",
"rules": {
"indentation": "tab",
"number-leading-zero": null
}
}
)]))
.pipe(sourcemaps.write('../css/maps'))
.pipe(gulp.dest("./css"))
.pipe(browserSync.stream({match: '**/*.css'}));
});
// Compile Bootstrap sass for production
gulp.task('sassBootstrap', function() {
return gulp.src("./scss_bootstrap/**/*.scss")
// outputStyle
// Type: String Default: nested Values: nested, expanded, compact, compressed
.pipe(sass({outputStyle: 'compressed'}).on('error', sass.logError))
.pipe(postcss([ autoprefixer({
"browsers": [
"> 0.1%"
]
}), flexbugs(), stylefmt(
{
"extends": "stylelint-config-suitcss",
"rules": {
"indentation": "tab",
"number-leading-zero": null
}
}
)]))
.pipe(gulp.dest("./css"))
.pipe(browserSync.stream({match: '**/*.css'}));
});
gulp.task('default', ['serve']);
// JS task - running manually - concat, strip debugging and minify
gulp.task('scripts', function() {
gulp.src(scripts)
.pipe(uglify({
output: {
comments: "/^!|opyright/"
}
}))
.pipe(concat('compressed.js'))
.pipe(gulp.dest('js/'));
});