forked from webdevsuperfast/bootstrap-for-genesis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
120 lines (106 loc) · 3.27 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
var gulp = require('gulp'),
sass = require('gulp-sass'),
postcss = require('gulp-postcss'),
jshint = require('gulp-jshint'),
uglify = require('gulp-uglify'),
rename = require('gulp-rename'),
concat = require('gulp-concat'),
notify = require('gulp-notify'),
merge = require('merge-stream'),
foreach = require('gulp-flatmap'),
changed = require('gulp-changed'),
browserSync = require('browser-sync').create(),
wpPot = require('gulp-wp-pot'),
cssnano = require('cssnano'),
cmq = require('css-mqpacker'),
autoprefixer = require('autoprefixer');
var plugins = [
autoprefixer,
cssnano,
cmq
]
var paths = {
styles: {
src: 'assets/scss/style.scss',
dest: 'assets/css'
},
scripts: {
src: [
'assets/js/source/app.js',
'node_modules/jquery/dist/jquery.slim.js',
'node_modules/bootstrap/dist/js/bootstrap.js',
'node_modules/popper.js/dist/umd/popper.js',
'node_modules/smartmenus/dist/jquery.smartmenus.js',
'node_modules/smartmenus-bootstrap-4/jquery.smartmenus.bootstrap-4.js'
],
dest: 'assets/js'
},
languages: {
src: '**/*.php',
dest: 'languages/bootstrap-for-genesis.pot'
},
site: {
url: 'http://bootstrap.test'
}
}
function translation() {
return gulp.src(paths.languages.src)
.pipe(wpPot())
.pipe(gulp.dest(paths.languages.dest))
}
function scriptsLint() {
return gulp.src('assets/js/source/**/*','gulpfile.js')
.pipe(jshint('.jshintrc'))
.pipe(jshint.reporter('default'))
}
function style() {
var cssStream = gulp.src('node_modules/smartmenus-bootstrap-4/jquery.smartmenus.bootstrap-4.css')
.pipe(concat('smartmenus.css'));
var sassStream = gulp.src(paths.styles.src)
.pipe(sass.sync().on('error', sass.logError))
.pipe(concat('app.scss'));
var mergeStream = merge(sassStream, cssStream)
.pipe(changed(paths.styles.dest))
.pipe(concat('app.css'))
.pipe(postcss(plugins))
.pipe(rename('app.css'))
.pipe(gulp.dest(paths.styles.dest))
.pipe(browserSync.stream())
.pipe(notify({ message: 'Styles task complete' }));
return mergeStream;
}
function js() {
return gulp.src(paths.scripts.src)
.pipe(changed(paths.scripts.dest))
.pipe(foreach(function(stream, file){
return stream
.pipe(uglify())
.pipe(rename({suffix: '.min'}))
}))
.pipe(gulp.dest(paths.scripts.dest))
.pipe(browserSync.stream({match: '**/*.js'}))
.pipe(notify({ message: 'Scripts task complete' }));
}
function browserSyncServe(done) {
browserSync.init({
injectChanges: true,
proxy: paths.site.url
})
done();
}
function browserSyncReload(done) {
browserSync.reload();
done();
}
function watch() {
gulp.watch(['assets/scss/*.scss', 'assets/scss/**/*.scss'], style).on('change', browserSync.reload)
gulp.watch(paths.scripts.src, gulp.series(scriptsLint, js))
gulp.watch([
'*.php',
'lib/*'
],
gulp.series(browserSyncReload)
)
}
gulp.task('translation', translation);
gulp.task('default', gulp.parallel(style, js, browserSyncServe, watch));