forked from Semantic-Org/Semantic-UI-LESS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
71 lines (62 loc) · 2 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
const gulp = require('gulp');
const less = require('gulp-less');
const postcss = require('gulp-postcss');
const rtl = require('postcss-rtl');
const autoprefixer = require('autoprefixer')
const cssnano = require('cssnano');
const concat = require('gulp-concat');
const replace = require('gulp-replace');
const rename = require('gulp-rename');
const argv = require('yargs').argv;
const path = require('path');
const settings = require('./semantic.json');
const buildCss = (theme) => async () => {
const dist = argv.dist || './dist';
await new Promise(resolve => {
gulp.src(`definitions/**/{${settings.components[theme].join(',')}}.less`)
.pipe(less({
globalVars: {
CURRENT_THEME: theme,
}
}))
.pipe(concat('main.min.css'))
.pipe(replace('../../themes/default/', './'))
.pipe(postcss([
autoprefixer(),
rtl(),
cssnano({
preset: ['default', {
discardComments: {
removeAll: true,
},
}]
})
]))
.pipe(gulp.dest(dist))
.on('end', resolve);
});
};
const buildAssets = (theme) => async () => {
const dist = argv.dist || './dist';
await new Promise(resolve => {
gulp.src(`themes/${theme}/assets/**/*.*`)
.pipe(rename((path) => {
path.dirname = path.dirname.split('/').pop();
return path;
}))
.pipe(gulp.dest(path.join(dist, 'assets/')))
.on('end', resolve);
});
};
const watchEhdaa = async () => {
gulp.watch('themes/ehdaa/**/*.(overrides|variables)', buildCss('ehdaa'));
};
const watchCoffeeman = async () => {
gulp.watch('themes/coffeeman/**/*.(overrides|variables)', buildCss('coffeeman'));
};
// exports.default = gulp.series(buildCss, buildAssets);
// exports.buildCss = buildCss;
exports.buildEhdaa = gulp.series(buildCss('ehdaa'), buildAssets('ehdaa'));
exports.buildCoffeeman = gulp.series(buildCss('coffeeman'), buildAssets('coffeeman'));
exports.watchEhdaa = watchEhdaa;
exports.watchCoffeeman = watchCoffeeman;