This repository has been archived by the owner on Mar 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
60 lines (54 loc) · 1.67 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
const { series, parallel, src, dest, watch } = require('gulp');
const babel = require('gulp-babel');
const uglify = require('gulp-uglify');
const strip = require('gulp-strip-comments');
const concat = require('gulp-concat');
const sass = require('gulp-sass')(require('sass'));
const cleanCSS = require('gulp-clean-css');
const prefix = require('gulp-autoprefixer');
const sourcemaps = require('gulp-sourcemaps');
const headerComment = require('gulp-header-comment');
const themeBasePath = './wordpress/wp-content/themes/Divi-child';
const paths = {
js: themeBasePath + '/js/main.js',
sassFolder: themeBasePath + '/scss/',
sass: themeBasePath + '/scss/main.scss',
};
/**
* MAIN
*/
function mainScss() {
return src([paths.sass])
.pipe(sass().on('error', sass.logError))
.pipe(sourcemaps.init())
.pipe(cleanCSS())
.pipe(prefix())
.pipe(concat('style.css'))
.pipe(headerComment(`
Theme Name: Divi Child
Theme URI: https://github.com/sebalaini/divi_custom_modules_for_reviews_website/
Description: Divi Child Theme
Author: sebalaini
Author URI: https://github.com/sebalaini/
Template: Divi
Version: 1.0.0
`))
.pipe(sourcemaps.write('.'))
.pipe(dest(themeBasePath));
}
function mainJs() {
return src(paths.js).pipe(strip()).pipe(babel()).pipe(uglify()).pipe(concat('theme.js')).pipe(dest(themeBasePath));
}
/**
* WATCH
*/
function watchtask() {
watch(paths.sassFolder, mainScss);
watch(paths.js, mainJs);
}
/**
* TASKS
*/
exports.default = series(parallel(mainScss, mainJs));
exports.sass = series(parallel(mainScss));
exports.watch = series(parallel(watchtask, mainJs));