-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgulpfile.js
51 lines (43 loc) · 1.85 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
'use strict';
const config = require('./config');
const gulp = require('gulp'),
clean = require('gulp-clean'),
concat = require('gulp-concat'),
uglify = require('gulp-uglify-es').default,
replace = require('gulp-string-replace'),
cleanCss = require('gulp-clean-css'),
babel = require("gulp-babel");
//clean build directory
gulp.task('clean', function() {
return gulp.src('public/min/*', {read: false})
.pipe(clean());
});
gulp.task('js', function() {
return gulp.src(['public/comments/comments.js', 'public/kudos/kudos.js'])
.pipe(replace(/kucosServerUrl = "(.*)"/g, 'kucosServerUrl = "'+config.kucosServerUrl+'"'))
.pipe(replace(/type="text\/css" href="\/min\/(.*)"/g, 'type="text/css" href="'+config.kucosServerUrl+'/min/kucos.min.css"'))
.pipe(babel())
.pipe(uglify())
.pipe(replace(/_defineProperty/g, '_f'))
.pipe(replace(' ', ''))
.pipe(concat('kucos.min.js'))
.pipe(gulp.dest('public/min'))
});
gulp.task('copy-assets', function() {
return gulp.src(['public/kudos/heart_60x60.png'])
.pipe(gulp.dest('public/min'));
});
gulp.task('copy', function () {
return gulp.src('public/assets/**/*')
.pipe(gulp.dest('public/min/assets'));
});
//minify styles
gulp.task('css', function() {
return gulp.src(['public/comments/comments.css', 'public/kudos/kudos.css', 'node_modules/highlight.js/styles/github.css'])
/*.pipe(minifycss({root: 'src/css', keepSpecialComments: 0}))*/
.pipe(replace(/background-image: url\(\/kudos\/heart_60x60\.png\);/g, 'background-image: url('+config.kucosServerUrl+'/min/heart_60x60.png);'))
.pipe(cleanCss({compatibility: "ie8", level: 2}))
.pipe(concat('kucos.min.css'))
.pipe(gulp.dest('public/min'));
});
gulp.task('default', gulp.series('clean', 'css', 'js', 'copy-assets', 'copy'));