forked from patternfly/patternfly
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.mjs
125 lines (101 loc) · 3.74 KB
/
gulpfile.mjs
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
import fs from'fs';
import path from 'path';
import gulp from'gulp';
import rimraf from'rimraf';
import { copyFA, copySource, copyAssets, copyDocs, watchCopyDocs } from'./scripts/gulp/copy.mjs';
import { compileSASS, minifyCSS, watchSASS } from'./scripts/gulp/sass.mjs';
import { pfIconFont as definedPfIconFont, pfIcons as definedPfIcons } from'./scripts/gulp/icons.mjs';
import { compileHBS, compileMD, watchHBS, watchMD, watchHelpers } from'./scripts/gulp/html.mjs';
import { lintCSSComments, lintCSSFunctions } from'./scripts/gulp/lint.mjs';
import { generateSnippets } from'./scripts/gulp/snippets.mjs';
import { start } from '@patternfly/documentation-framework/scripts/cli/start.js';
import { build as docsFrameworkBuild} from '@patternfly/documentation-framework/scripts/cli/build.js';
const { series, parallel } = gulp;
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'];
const helperFiles = ['./scripts/helpers.mjs'];
export 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(cb) {
return watchSASS(['./src/patternfly/**/*.scss', '!./src/patternfly/assets/**'], cb);
}
function compileSrcHBS() {
return compileHBS(hbsFiles);
}
function watchSrcHBS(cb) {
return watchHBS(hbsFiles, cb);
}
function compileSrcMD() {
return compileMD(mdFiles);
}
function watchSrcMD(cb) {
return watchMD(mdFiles, cb);
}
function watchSrcHelpers(cb) {
return watchHelpers(helperFiles, hbsFiles, cb);
}
function generateWorkspaceSnippets() {
return generateSnippets('workspace/**/index.html');
}
export const snippets = series(compileSrcHBS, compileSrcMD, generateWorkspaceSnippets);
const themeCLIOptions = {
parent: {
config: './patternfly-docs/patternfly-docs.config.js',
cssconfig: './patternfly-docs/patternfly-docs.css.js',
source: './patternfly-docs/patternfly-docs.source.js'
}
};
export async function buildWebpack() {
await docsFrameworkBuild('all', themeCLIOptions);
}
async function startWebpackDevServer() {
await start(themeCLIOptions);
// temporary auto deletion of public dir due to docs-framework bug
rimraf(path.join(process.cwd(), 'public'), {}, () => {})
}
const buildSrc = parallel(compileSrcSASS, series(compileSrcHBS, compileSrcMD));
const buildDocs = series(buildSrc, copyDocs);
const watchAll = parallel(watchSrcSASS, watchSrcHBS, watchSrcMD, watchCopyDocs, watchSrcHelpers, startWebpackDevServer);
// Builds `dist` folder
export const buildPatternfly = parallel(series(buildDocs, minifyCSS), pfIcons, copyFA, copySourceFiles);
export const build = series(buildPatternfly, buildWebpack); // Builds `dist` and `public` folders
export function pfIcons() {
return definedPfIcons();
}
export function pfIconFont() {
return definedPfIconFont();
}
export const develop = series(buildPatternfly, watchAll);
export const lintCSS = parallel(lintCSSFunctions, lintCSSComments);