forked from picturepan2/spectre
-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
116 lines (104 loc) · 2.66 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
106
107
108
109
110
111
112
113
114
115
116
const gulp = require("gulp");
const { series, parallel } = require("gulp");
const sass = require('gulp-sass')(require('sass'));
const cleancss = require('gulp-clean-css');
// const csscomb = require('gulp-csscomb');
const rename = require('gulp-rename');
const run = require('gulp-run');
const pug = require('gulp-pug');
const autoprefixer = require('gulp-autoprefixer');
function build() {
return gulp
.src('./src/*.scss')
.pipe(sass({outputStyle: 'expanded'})
.on('error', sass.logError)
)
.pipe(autoprefixer())
.pipe(gulp.dest('./dist'))
.pipe(cleancss())
.pipe(rename({
suffix: '.min'
}))
.pipe(gulp.dest('./dist'));
}
function build_colors(cb) {
const modules = [
'buttons',
'hero',
'labels',
'pagination',
'toasts'
];
modules.forEach(function(module) {
gulp
.src([
'./src/' + module + '/colors/*.scss',
'./src/' + module + '/colors/**/*.scss'
])
.pipe(sass({outputStyle: 'expanded'})
.on('error', sass.logError)
)
.pipe(autoprefixer())
.pipe(gulp.dest('./dist/' + module))
.pipe(gulp.dest('./docs/dist/' + module))
.pipe(cleancss())
.pipe(rename({
suffix: '.min'
}))
.pipe(gulp.dest('./dist/' + module))
.pipe(gulp.dest('./docs/dist/' + module));
});
cb();
}
function dist_clean(cb) {
run('npm run remove:prod:dist').exec();
cb();
}
function docs_clean(cb) {
docs_clean_dist(cb);
docs_clean_html(cb);
cb();
}
function docs_clean_dist(cb) {
run('npm run remove:docs:dist').exec();
cb();
}
function docs_clean_html(cb) {
run('npm run remove:docs:html').exec();
cb();
}
function build_docs_css(cb) {
gulp
.src(['./src/*.scss', './docs/src/scss/*.scss'])
.pipe(sass.sync({outputStyle: 'expanded', precision: 10})
.on('error', sass.logError)
)
.pipe(autoprefixer())
// .pipe(csscomb())
.pipe(gulp.dest('./docs/dist'))
.pipe(cleancss())
.pipe(rename({
suffix: '.min'
}))
.pipe(gulp.dest('./docs/dist'));
cb();
}
function build_docs_html() {
return gulp
.src('docs/src/**/!(_)*.pug')
.pipe(pug({
pretty: true
}))
.pipe(gulp.dest('./docs/'));
}
function watch() {
gulp.watch('./**/*.scss', parallel(build, build_docs_css));
gulp.watch('./**/*.pug', build_docs_html);
}
exports.watch = watch;
exports.build = series(dist_clean, parallel(build, build_colors));
exports.build_colors = build_colors;
exports.build_docs = series(docs_clean, parallel(build_docs_css, build_colors, build_docs_html));
exports.build_docs_css = series(docs_clean_dist, parallel(build_docs_css, build_colors));
exports.build_docs_html = build_docs_html;
exports.default = build;