A bit of DRYing in Gulpfile

This commit is contained in:
Benedek Farkas
2025-10-01 16:25:51 +02:00
parent 3a38a952ac
commit bb263cba6a

View File

@@ -196,11 +196,7 @@ function buildCssPipeline(assetGroup, doConcat, doRebuild) {
.pipe(postcss([ .pipe(postcss([
autoprefixer({ browsers: ["last 2 versions"] }) autoprefixer({ browsers: ["last 2 versions"] })
])) ]))
.pipe(header( .pipe(header(getOutputFileHeader()))
"/*\n" +
"** NOTE: This file is generated by Gulp and should not be edited directly!\n" +
"** Any changes made directly to this file will be overwritten next time its asset group is processed by Gulp.\n" +
"*/\n\n"))
.pipe(gulpif(generateSourceMaps, sourcemaps.write())) .pipe(gulpif(generateSourceMaps, sourcemaps.write()))
.pipe(eol()) .pipe(eol())
.pipe(rename(function (path) { .pipe(rename(function (path) {
@@ -239,11 +235,7 @@ function buildJsPipeline(assetGroup, doConcat, doRebuild) {
.pipe(plumber()) .pipe(plumber())
.pipe(gulpif(generateSourceMaps, sourcemaps.init())) .pipe(gulpif(generateSourceMaps, sourcemaps.init()))
.pipe(typescript(typeScriptOptions)) // TypeScript doesn't support JavaScript modules. .pipe(typescript(typeScriptOptions)) // TypeScript doesn't support JavaScript modules.
.pipe(header( .pipe(header(getOutputFileHeader()))
"/*\n" +
"** NOTE: This file is generated by Gulp and should not be edited directly!\n" +
"** Any changes made directly to this file will be overwritten next time its asset group is processed by Gulp.\n" +
"*/\n\n"))
.pipe(gulpif(generateSourceMaps, sourcemaps.write())) .pipe(gulpif(generateSourceMaps, sourcemaps.write()))
.pipe(eol()) .pipe(eol())
.pipe(rename(function (path) { .pipe(rename(function (path) {
@@ -261,3 +253,12 @@ function buildJsPipeline(assetGroup, doConcat, doRebuild) {
})) }))
.pipe(gulp.dest(assetGroup.outputDir)); .pipe(gulp.dest(assetGroup.outputDir));
} }
function getOutputFileHeader() {
return (
"/*\n" +
"** NOTE: This file is generated by Gulp and should not be edited directly!\n" +
"** Any changes made directly to this file will be overwritten next time its asset group is processed by Gulp.\n" +
"*/\n\n"
);
}