-
Notifications
You must be signed in to change notification settings - Fork 3
/
gulpfile.js
79 lines (72 loc) · 1.99 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
"use strict";
const gulp = require('gulp');
const plumber = require('gulp-plumber');
const sourcemaps = require('gulp-sourcemaps');
const rename = require("gulp-rename");
const sass = require('gulp-sass');
const autoprefixer = require('gulp-autoprefixer');
const cleanCss = require('gulp-clean-css');
const uglify = require('gulp-uglify');
const zip = require('gulp-zip');
function buildCss() {
return gulp.src('./assets/src/scss/*.scss')
.pipe(plumber())
.pipe(sourcemaps.init())
.pipe(sass({
outputStyle: 'expanded'
}))
.pipe(autoprefixer({
browsers: ['last 2 versions']
}))
.pipe(gulp.dest('./assets/css/'))
.pipe(cleanCss())
.pipe(rename({
suffix: '.min'
}))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('./assets/css/'));
}
function buildJs() {
return gulp.src([
'./assets/js/*.js',
'!./assets/js/*.min.js'
])
.pipe(plumber())
.pipe(sourcemaps.init())
.pipe(uglify())
.pipe(rename({
suffix: '.min'
}))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('./assets/js/'));
}
function watchCss() {
return gulp.watch(['./assets/src/scss/*.scss'], buildCss);
}
function watchJs() {
return gulp.watch([
'./assets/js/*.js',
'!./assets/js/*.min.js'
], buildJs);
}
function makeZip() {
return gulp.src([
'**',
'!.*',
'!assets/src/**',
'!node_modules/**',
'!gulpfile.js',
'!package.json',
'!yarn.lock'
], {
base: '../'
})
.pipe(zip('fr-address-book-for-woocommerce.zip'))
.pipe(gulp.dest('../'));
}
gulp.task('build:css', buildCss);
gulp.task('build:js', buildJs);
gulp.task('watch:css', watchCss);
gulp.task('watch:js', watchJs);
gulp.task('watch', gulp.parallel('watch:css', 'watch:js'));
gulp.task('zip', makeZip);