-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
102 lines (93 loc) · 2.81 KB
/
gulpfile.js
File metadata and controls
102 lines (93 loc) · 2.81 KB
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
const { src, dest, series } = require('gulp');
const uglify = require('gulp-uglify');
const rename = require('gulp-rename');
const gulpsass = require('gulp-sass')(require('sass'));
const autoprefixer = require('gulp-autoprefixer');
const sourcemaps = require('gulp-sourcemaps');
const pipeline = require('readable-stream').pipeline;
const markdown = require('gulp-markdown');
const footer = require('gulp-footer');
const fs = require('fs');
const sassSrc = 'sass/*.scss';
const sassDest = 'docs/assets/css/';
const jsSrc = 'index.js';
const jsDest = 'docs/assets/js';
const cssFile = 'docs/assets/css/swalstrap.min.css';
const distributionCss = 'dist/css/';
const distributionJs = 'dist/js/';
function sass() {
return src(sassSrc)
.pipe(autoprefixer())
.pipe(gulpsass().on('error', (err) => console.log(err)))
.pipe(dest(sassDest));
}
function documentation() {
return src('README.md')
.pipe(markdown())
.pipe(rename('documentation.xml'))
.pipe(dest('docs'))
}
function documentation_it() {
return src('LEGGIMI.md')
.pipe(markdown())
.pipe(rename('documentation-it.xml'))
.pipe(dest('docs'))
}
function sasscompress() {
return src(sassSrc)
.pipe(autoprefixer())
.pipe(sourcemaps.init())
.pipe(gulpsass({ outputStyle: 'compressed' }))
.pipe(rename({ extname: '.min.css' }))
.pipe(sourcemaps.write('.'))
.pipe(dest(sassDest));
}
function compressjs() {
return pipeline(
src(jsSrc),
uglify(),
rename('swalstrap5.min.js'),
dest(jsDest),
src(jsSrc),
rename('swalstrap5.js'),
dest(jsDest)
);
}
function createAutoInstall() {
const cssContent = fs.readFileSync(cssFile);
return pipeline(
src(jsSrc),
footer(`;(function (win, doc) {
win.Swal = win.swal = win.Sweetalert = win.sweetalert = new Swalstrap();
const style = doc.createElement('style');
style.innerText = \`${cssContent}\`;
doc.head.appendChild(style);
})(window, document)`),
uglify(),
rename('swalstrap5_all.min.js'),
dest(jsDest),
src(jsSrc),
footer(`
;(function (win, doc) {
win.Swal = win.swal = win.Sweetalert = win.sweetalert = new Swalstrap();
const style = doc.createElement('style');
style.innerText = \`${cssContent}\`;
doc.head.appendChild(style);
})(window, document)`),
rename('swalstrap5_all.js'),
dest(jsDest)
);
}
function creadist() {
return pipeline(
src('docs/assets/**'),
dest('dist/')
)
}
exports.default = series(sass, sasscompress, compressjs, createAutoInstall, creadist, documentation, documentation_it);
exports.sass = sass;
exports.compressjs = compressjs;
exports.sasscompress = sasscompress;
exports.creadist = creadist;
exports.documentation = documentation;
exports.documentation_it = documentation_it;