-
Notifications
You must be signed in to change notification settings - Fork 2
/
gulpfile.js
105 lines (88 loc) · 2.89 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
var gulp = require('gulp'),
sass = require('gulp-sass'),
concat = require('gulp-concat'),
merge = require('merge-stream'),
watch = require('gulp-watch'),
replace = require('gulp-replace'),
minifyCSS = require('gulp-clean-css'),
minifyJS = require('gulp-uglify'),
theme = ['./src/theme/**/*'],
js = ['./src/js/*'],
watchPaths = ['./src/sass/*.scss', './src/theme/**/*'];
function createCSSFiles(variable, file, compressedFile) {
variable.pipe(concat(file))
.pipe(gulp.dest('css/'));
return variable.pipe(concat(compressedFile))
.pipe(replace('/*', '/*!'))
.pipe(minifyCSS())
.pipe(gulp.dest('css/'));
}
function renderCSS() {
var screenSCSS = ['./src/sass/screen.scss'],
printSCSS = ['./src/sass/print.scss'],
rtlSCSS = ['./src/sass/rtl.scss'],
editorSCSS = ['./src/sass/editor-style.scss'],
reset = ['node_modules/reset.css/reset.css'];
var screen = merge(
gulp.src(screenSCSS).pipe(sass()),
gulp.src(reset)
);
var print = gulp.src(printSCSS)
.pipe(sass());
var rtl = gulp.src(rtlSCSS)
.pipe(sass());
var editor = gulp.src(editorSCSS)
.pipe(sass());
createCSSFiles(screen, 'screen.css', 'screen.min.css');
createCSSFiles(print, 'print.css', 'print.min.css');
createCSSFiles(editor, 'editor-style.css', 'editor-style.min.css');
return createCSSFiles(rtl, 'rtl.css', 'rtl.min.css');
}
function compressJS(variable, filename) {
return variable.pipe(minifyJS({
output: {
comments: "all"
}
}))
.pipe(concat(filename))
.pipe(gulp.dest('./js/'));
}
function renderJS() {
var bootstrap = merge(
gulp.src('node_modules/bootstrap/js/tooltip.js'),
gulp.src('node_modules/bootstrap/js/popover.js')
),
enigma = gulp.src('./src/js/jquery.enigma.js'),
scrollupformenu = gulp.src('./src/js/jquery.scrollupformenu.js');
bootstrap.pipe(concat('bootstrap.js'))
.pipe(gulp.dest('./js/'));
compressJS(scrollupformenu, 'jquery.scrollupformenu.min.js');
compressJS(enigma, 'jquery.enigma.min.js');
compressJS(bootstrap, 'bootstrap.min.js');
return gulp.src(js)
.pipe(gulp.dest('./js/'));
}
gulp.task('stylesheets', function () {
return renderCSS();
})
gulp.task('js', function () {
return renderJS();
})
gulp.task('theme', function () {
return gulp.src(theme)
.pipe(gulp.dest('.'));
})
gulp.task('dev', function () {
return gulp.watch(watchPaths, gulp.parallel('stylesheets', 'js', 'theme'));
})
gulp.task('make', function () {
gulp.series('stylesheets', 'js');
gulp.src('license.txt')
.pipe(gulp.dest('dist/'));
gulp.src('css/*')
.pipe(gulp.dest('dist/css/'));
gulp.src('js/*')
.pipe(gulp.dest('dist/js/'));
return gulp.src(theme)
.pipe(gulp.dest('dist/'));
})