forked from patternfly/patternfly
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
131 lines (114 loc) · 3.68 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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
const fs = require('fs');
const { series, parallel } = require('gulp');
const rimraf = require('rimraf');
const { copyFA, copySource, copyAssets, copyDocs, watchCopyDocs } = require('./scripts/gulp/copy');
const { compileSASS, minifyCSS, watchSASS } = require('./scripts/gulp/sass');
const { pfIconFont, pfIcons } = require('./scripts/gulp/icons');
const { compileHBS, compileMD, watchHBS, watchMD } = require('./scripts/gulp/html');
const { lintCSSComments, lintCSSFunctions } = require('./scripts/gulp/lint');
const { generateSnippets } = require('./scripts/gulp/snippets');
const { start } = require('@patternfly/documentation-framework/scripts/cli/start');
const { build } = require('@patternfly/documentation-framework/scripts/cli/build');
const sassFiles = [
'./src/patternfly/patternfly*.scss',
'./src/patternfly/base/patternfly*.scss',
'./src/patternfly/{components,layouts,patterns,utilities}/**/*.scss',
'!./src/patternfly/**/_all.scss',
// No need to compile component theme sass files to empty css files
'!./src/patternfly/components/**/themes/**/*.scss'
];
const hbsFiles = ['./src/patternfly/**/*.hbs'];
const mdFiles = ['./src/patternfly/**/*.md'];
function clean(cb) {
const cleanGlobs = [
'dist',
'src/icons/PfIcons',
'.circleci/css-size-report/node_modules',
'.circleci/css-size-report/package-lock.json',
'.circleci/css-size-report/report.html',
'src/icons/PfIcons/',
'static/assets/fontawesome/',
'static/assets/fonts/',
'static/assets/pficon/',
'test/results/',
'test/scenario_tests/',
'.cache',
'public',
'patternfly-docs/generated/**/*.js'
];
cleanGlobs.forEach(glob => rimraf.sync(glob));
cb();
}
function copySourceFiles() {
return copySource();
}
function compileSrcSASS() {
return compileSASS(sassFiles);
}
function watchSrcSASS() {
return watchSASS(['./src/patternfly/**/*.scss', '!./src/patternfly/assets/**']);
}
function compileSrcHBS() {
return compileHBS(hbsFiles);
}
function watchSrcHBS() {
return watchHBS(hbsFiles);
}
function compileSrcMD() {
return compileMD(mdFiles);
}
function watchSrcMD() {
return watchMD(mdFiles);
}
function generateWorkspaceSnippets() {
return generateSnippets('workspace/**/index.html');
}
const themeCLIOptions = {
parent: {
config: './patternfly-docs/patternfly-docs.config.js',
cssconfig: './patternfly-docs/patternfly-docs.css.js',
source: './patternfly-docs/patternfly-docs.source.js'
}
};
async function buildWebpack() {
await build('all', themeCLIOptions);
}
function startWebpackDevServer() {
start(themeCLIOptions);
}
const buildSrc = parallel(compileSrcSASS, series(compileSrcHBS, compileSrcMD));
const buildDocs = series(buildSrc, copyDocs);
const watchAll = parallel(watchSrcSASS, watchSrcHBS, watchSrcMD, watchCopyDocs, startWebpackDevServer);
// Builds `dist` folder
const buildPatternfly = parallel(series(buildDocs, minifyCSS), pfIcons, copyFA, copySourceFiles);
function checkBuildPatternfly(cb) {
if (!fs.existsSync('dist')) {
buildPatternfly(cb);
} else {
cb();
}
}
module.exports = {
build: series(buildPatternfly, buildWebpack), // Builds `dist` and `public` folders
buildPatternfly, // Builds `dist` folder
buildWebpack, // Builds `public` folder
develop: series(checkBuildPatternfly, buildDocs, watchAll),
compileSASS: compileSrcSASS,
minifyCSS,
watchSASS: watchSrcSASS,
watchHBS: watchSrcHBS,
watchMD: watchSrcMD,
watchCopyDocs,
clean,
pfIconFont,
pfIcons,
copyFA,
copySource: copySourceFiles,
copyAssets,
copyDocs,
lintCSSFunctions,
lintCSSComments,
lintCSS: parallel(lintCSSFunctions, lintCSSComments),
snippets: series(compileSrcHBS, compileSrcMD, generateWorkspaceSnippets),
compileSrcSASS
};