This commit is contained in:
Philippe Torrel
2026-08-05 09:49:28 +02:00
parent 07dfcec4ef
commit c548ea97a1
32 changed files with 4588 additions and 1956 deletions

View File

@@ -66,6 +66,9 @@ task('css', (done) => {
// JS bzw. TS ==================================
import { spawn } from 'node:child_process';
import { fileURLToPath } from 'node:url';
import path from 'node:path';
import rollupStream from '@rollup/stream';
import { babel } from '@rollup/plugin-babel'; // Plugin für rollup. JS Dateien werden über Babel direkt beim bundlen in "altes" JS über babel kompiliert
import { nodeResolve } from '@rollup/plugin-node-resolve'; // import Kurzschreibweise (suche Module im node_modules Ordner)
@@ -73,12 +76,27 @@ import commonJs from '@rollup/plugin-commonjs'; // commonjs module werden module
import source from 'vinyl-source-stream';
import buffer from 'vinyl-buffer';
import rollupReplace from '@rollup/plugin-replace'; // Umbenennung von Variablen in den Modulen möglich
import typescript from '@rollup/plugin-typescript'; // For TypeScript support needs "typescript" and "tslib"
import esbuild from 'rollup-plugin-esbuild'; // TypeScript strippen ohne TS-Compiler-API (TS 7+ kompatibel)
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const tscBin = path.join(__dirname, 'node_modules', 'typescript', 'bin', 'tsc');
// declare the cache variable outside of task scopes
let cache;
// $ gulp ts
// $ gulp typecheck — Typen prüfen (tsc CLI, kein Emit)
task('typecheck', (done) => {
const child = spawn(process.execPath, [tscBin, '--noEmit'], {
stdio: 'inherit',
cwd: __dirname,
});
child.on('error', done);
child.on('close', (code) => {
done(code === 0 ? undefined : new Error(`typecheck failed with exit code ${code}`));
});
});
// $ gulp ts — Bundle (esbuild strippt Types, Babel downlevelt für Browser)
task('ts', () => {
// Updated path to look in dev/scripts for a main.ts file
const sourceFile = './dev/scripts/main.ts';
@@ -93,7 +111,14 @@ task('ts', () => {
// define the cache in Rollup options
cache,
plugins: [
typescript(), // Added TypeScript plugin
esbuild({
include: /\.[jt]sx?$/,
exclude: /node_modules/,
sourceMap: true,
// Babel übernimmt Browser-Downleveling; esbuild nur TS→JS
target: 'esnext',
tsconfig: './tsconfig.json',
}),
rollupReplace({
'process.env.NODE_ENV': JSON.stringify('development'),
preventAssignment: true,
@@ -107,7 +132,7 @@ task('ts', () => {
plugins: ['@babel/plugin-transform-runtime'], // kontrolliert, ob ein Modul bereits eingebunden und bindet es nicht erneut ein
babelHelpers: 'runtime',
compact: true,
extensions: ['.js', '.ts'], // Tell babel to process TS files
extensions: ['.js', '.ts'],
}),
],
})
@@ -168,6 +193,7 @@ task('watcher', () => {
// ==== DEV MODE ====================
task('dev', series('css', 'ts', 'html', parallel('watcher', 'server')));
task('check', series('typecheck', 'ts'));
// ===================================
task('test', (done) => {