-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathgulpfile.js
95 lines (83 loc) · 3.01 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
const gulp = require('gulp');
const postcss = require('gulp-postcss');
const concat = require('gulp-concat');
const postcssImport = require('postcss-import');
const postcssSimpleVars = require('postcss-simple-vars');
const postcssCalc = require('postcss-calc');
const postcssNested = require('postcss-nested');
const postcssReporter = require('postcss-reporter');
const postcssColorFunction = require('postcss-color-function');
const autoprefixer = require('autoprefixer');
const csso = require('gulp-csso');
const rename = require('gulp-rename');
const replace = require("gulp-string-replace");
const del = require('del');
const srcPath = './node_modules/whitepaper-bem';
const srcLevels = [
srcPath + '/theme/**/*.css', // Тема
srcPath + '/tpl-*/**/*.css', // Каркас
srcPath + '/pt-*/**/*.css', // Паттерны
srcPath + '/text/_font/**/*.css', // Контент / Текст
srcPath + '/text/_display/**/*.css', // Контент / Текст
srcPath + '/text/_size/**/*.css', // Контент / Текст
srcPath + '/text/_line-height/**/*.css', // Контент / Текст
srcPath + '/text/_align/**/*.css', // Контент / Текст
srcPath + '/text/_decoration/**/*.css', // Контент / Текст
srcPath + '/text/_spacing/**/*.css', // Контент / Текст
srcPath + '/text/_style/**/*.css', // Контент / Текст
srcPath + '/text/_transform/**/*.css', // Контент / Текст
srcPath + '/text/_view/**/*.css', // Контент / Текст
srcPath + '/text/_weight/**/*.css', // Контент / Текст
srcPath + '/text/_width/**/*.css', // Контент / Текст
srcPath + '/text/_type/**/*.css', // Контент / Текст
srcPath + '/avatar/**/*.css', // Контент
srcPath + '/badge/**/*.css', // Контент
srcPath + '/icon/**/*.css', // Контент
srcPath + '/social-icon/**/*.css', // Контент
srcPath + '/tag/**/*.css', // Контент
srcPath + '/vector/**/*.css', // Контент
srcPath + '/decorator/**/*.css' // Декоратор
];
const destPath = './cdn/';
const name = 'whitepaper';
let version = '';
const replaceVersion = rawString => {
const newString = rawString.replace(/"version":\s*/g, '');
const withoutQuotes = newString.substring(1, newString.length - 1).replace('"', '');
version = withoutQuotes;
return rawString;
};
gulp.task('clean', () => {
del(destPath);
});
gulp.task('get-version', () => {
return gulp.src(srcPath + '/package.json')
.pipe(replace(/"version".*$/gm, replaceVersion))
});
gulp.task('css', () => {
let plugins = [
postcssImport(),
postcssSimpleVars(),
postcssCalc(),
postcssNested,
autoprefixer(),
postcssColorFunction(),
postcssReporter()
];
return gulp.src(srcLevels)
.pipe(postcss(plugins))
.pipe(concat(name + '-' + version + '.css'))
// .pipe(rmComments())
.pipe(gulp.dest(destPath))
.pipe(csso())
.pipe(rename({ suffix: '.min' }))
.pipe(gulp.dest(destPath));
});
gulp.task(
'default',
gulp.series(
// "clean",
'get-version',
'css'
)
);