generated from adobe/aem-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 5
/
gulpfile.js
111 lines (99 loc) · 2.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
const {
series, dest, src, watch,
} = require('gulp');
const postcss = require('gulp-postcss');
const sourcemaps = require('gulp-sourcemaps');
const plumber = require('gulp-plumber');
const gutil = require('gulp-util');
const rename = require('gulp-rename');
const header = require('gulp-header');
const generatedHeader = '/* stylelint-disable */\n/* Generated File: Do not edit directly */\n';
/**
* UTIL TASKS
*/
const errorMsg = '\x1b[41mError\x1b[0m';
function onError(err) {
gutil.beep();
gutil.log(`${errorMsg} ${err.toString()}`);
// @ts-ignore
this.emit('end');
}
function buildSystem() {
return src('./styles/system/index.css')
.pipe(plumber({ errorHandler: onError }))
.pipe(postcss())
.pipe(header(generatedHeader))
.pipe(rename('system.css'))
.pipe(dest('./styles'));
}
function buildStorybookCss() {
return src('.storybook/story.post.css')
.pipe(plumber({ errorHandler: onError }))
.pipe(postcss())
.pipe(header(generatedHeader))
.pipe(rename('story.css'))
.pipe(dest('.storybook/'));
}
function buildBlocks() {
return src('blocks/**/*.post.css')
.pipe(plumber({ errorHandler: onError }))
.pipe(sourcemaps.init())
.pipe(postcss())
.pipe(
rename((file) => ({
dirname: `blocks/${file.dirname}/`,
basename: `${file.basename.replace('.post', '')}`,
extname: '.css',
})),
)
.pipe(header(generatedHeader))
.pipe(dest('.'));
}
function buildComponents() {
return src('components/**/*.post.css')
.pipe(plumber({ errorHandler: onError }))
.pipe(sourcemaps.init())
.pipe(postcss())
.pipe(
rename((file) => ({
dirname: `components/${file.dirname}/`,
basename: `${file.basename.replace('.post', '')}`,
extname: '.css',
})),
)
.pipe(header(generatedHeader))
.pipe(dest('.'));
}
function buildTemplates() {
return src('templates/**/*.post.css')
.pipe(plumber({ errorHandler: onError }))
.pipe(sourcemaps.init())
.pipe(postcss())
.pipe(
rename((file) => ({
dirname: `templates/${file.dirname}/`,
basename: `${file.basename.replace('.post', '')}`,
extname: '.css',
})),
)
.pipe(header(generatedHeader))
.pipe(dest('.'));
}
function startWatching() {
watch(['./**/*.post.css', './styles/system/**/*.css', '.storybook/**/*.post.css'], undefined, series(buildSystem, buildBlocks, buildComponents, buildStorybookCss, buildTemplates));
}
exports.dev = series(
buildSystem,
buildBlocks,
buildComponents,
buildStorybookCss,
buildTemplates,
startWatching,
);
exports.build = series(
buildSystem,
buildBlocks,
buildComponents,
buildStorybookCss,
buildTemplates,
);