-
Notifications
You must be signed in to change notification settings - Fork 5
/
gulpfile.js
56 lines (48 loc) · 1.72 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
'use strict';
var gulp = require('gulp'),
sourcemaps = require('gulp-sourcemaps'),
uglify = require('gulp-uglify'),
rename = require('gulp-rename'),
cssmin = require('gulp-cssmin'),
concat = require('gulp-concat'),
babel = require('gulp-babel');
// CSS COMPRESS
gulp.task('compress-css', function () {
return gulp.src('css/src/*.css')
.pipe(cssmin())
.pipe(rename({suffix: '.min'}))
.pipe(gulp.dest('css'));
});
// JS COMPRESS
function compress_all_js() {
return gulp.src(['js/src/*.js', '!js/src/apbct-public--*.js', '!js/src/apbct-public-bundle.js', 'js/src/apbct-public--3--cleantalk-modal.js', 'js/src/apbct-public--7--trp.js'])
.pipe(sourcemaps.init())
.pipe(uglify())
.pipe(rename({suffix: '.min'}))
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('js'));
}
// Bundle Create
function bundle_src_js() {
return gulp.src('js/src/apbct-public--*.js')
// Unminified bundle
.pipe(concat('apbct-public-bundle.js'))
.pipe(gulp.dest('js/src/'));
}
function bundle_js() {
return gulp.src('js/src/apbct-public-bundle.js')
.pipe(babel({
presets: [["@babel/preset-env", { targets: { ie: "11" } }]],
plugins: ["@babel/plugin-transform-class-properties"]
}))
.pipe(uglify())
.pipe(rename({suffix: '.min'}))
.pipe(gulp.dest('js'));
}
gulp.task('compress-js', gulp.series(bundle_src_js, bundle_js, compress_all_js));
gulp.task('compress-css:watch', function () {
gulp.watch('./css/src/*.css', gulp.parallel('compress-css'));
});
gulp.task('compress-js:watch', function () {
gulp.watch('./js/src/*.js', gulp.parallel('compress-js'));
});