forked from osano/cookieconsent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
76 lines (64 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
var gulp = require('gulp');
var sass = require('gulp-sass');
var uglify = require('gulp-uglify');
var rename = require("gulp-rename");
var replace = require("gulp-replace");
var yargs = require("yargs");
var del = require("del");
var runSequence = require("run-sequence");
var baseCdnUrl = '//cdnjs.cloudflare.com/ajax/libs/cookieconsent2/';
gulp.task('sass:copy', function(){
return gulp.src('./styles/**/*')
.pipe(gulp.dest('sass-tmp'));
});
gulp.task('sass:tag', function(){
if (yargs.argv.tag===undefined) {
return;
}
return gulp.src("./sass-tmp/_variables.scss")
.pipe(replace(/(\$logo:(?: )?url\()(.*)(\);)/, '$1' + baseCdnUrl + yargs.argv.tag+'/logo.png$3'))
.pipe(gulp.dest('./sass-tmp'));
//.pipe(gulp.dest('./tmp'));
});
gulp.task('sass:build', function(){
return gulp.src('./sass-tmp/*.scss')
.pipe(sass({outputStyle: 'compressed'}))
.pipe(gulp.dest('./build'));
});
gulp.task('minify', function () {
var pipeline = gulp.src('./cookieconsent.js');
if (yargs.argv.tag!==undefined) {
pipeline.pipe(replace(/(var THEME_BUCKET_PATH(?: )*=(?: )*')(.*)(';)/, '$1' + baseCdnUrl + yargs.argv.tag+'/$3'));
}
return pipeline
.pipe(uglify())
.pipe(rename('cookieconsent.min.js'))
.pipe(gulp.dest('./build'));
});
gulp.task('copy:images', function() {
return gulp.src('./images/*')
.pipe(gulp.dest('./build'));
});
gulp.task('cleanup:begin', function() {
return del([
"./sass-tmp",
"./build"
]);
});
gulp.task('cleanup:end', function() {
return del([
"./sass-tmp"
]);
});
gulp.task('build', function(callback){
runSequence(
'cleanup:begin',
'minify',
'sass:copy',
'sass:tag',
'sass:build',
'copy:images',
'cleanup:end',
callback
);
});