|
|
@ -1,7 +1,5 @@ |
|
|
|
import yargs from 'yargs'; |
|
|
|
import gulp from 'gulp'; |
|
|
|
import gf from 'get-google-fonts'; |
|
|
|
import sharp from 'gulp-sharp-responsive'; |
|
|
|
import concat from 'gulp-concat'; |
|
|
|
import autoprefixer from 'gulp-autoprefixer'; |
|
|
|
import cleanCSS from 'gulp-clean-css'; |
|
|
@ -11,8 +9,9 @@ import {deleteSync} from 'del'; |
|
|
|
import axios from 'axios'; |
|
|
|
import fs from 'fs-extra'; |
|
|
|
import path from 'path'; |
|
|
|
import {config} from "./config.mjs" |
|
|
|
|
|
|
|
import imagemin from 'imagemin'; |
|
|
|
import imageminWebp from 'imagemin-webp'; |
|
|
|
import {config} from "./config.mjs"; |
|
|
|
const sass = gulpSass(dartSass); |
|
|
|
|
|
|
|
async function prepareSrc(mixedSources) { |
|
|
@ -114,12 +113,32 @@ async function buildFont(){ |
|
|
|
function cleanImg() { |
|
|
|
deleteSync([config.del.img]); |
|
|
|
} |
|
|
|
|
|
|
|
async function buildImg(){ |
|
|
|
await gulp.src(config.watch.img) |
|
|
|
.pipe(sharp({ |
|
|
|
formats: [{format: 'webp'}] |
|
|
|
})) |
|
|
|
.pipe(gulp.dest(config.dist + '/' + config.app)); |
|
|
|
const files = await imagemin([config.watch.img], { |
|
|
|
plugins: [ |
|
|
|
imageminWebp({ quality: 80 }), |
|
|
|
], |
|
|
|
}); |
|
|
|
|
|
|
|
// Verarbeite jede Datei und speichere sie |
|
|
|
await files.forEach(file => { |
|
|
|
const relativePath = path.relative(config.watch.img, file.sourcePath); |
|
|
|
const outputPath = config.dist + '/' + config.app + '/' + relativePath.replace(path.extname(relativePath), '.webp').replace('../../', ''); |
|
|
|
console.log(outputPath); |
|
|
|
// Stelle sicher, dass das Verzeichnis existiert |
|
|
|
ensureDirectoryExistence(outputPath); |
|
|
|
|
|
|
|
// Schreibe die konvertierte Datei in das Zielverzeichnis |
|
|
|
fs.writeFileSync(outputPath, file.data); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
function ensureDirectoryExistence(filePath) { |
|
|
|
const dir = path.dirname(filePath); |
|
|
|
if (!fs.existsSync(dir)) { |
|
|
|
fs.mkdirSync(dir, { recursive: true }); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
function watchImg() { |
|
|
|