merge 63
This commit is contained in:
commit
cd049e3477
2 changed files with 69 additions and 7 deletions
66
gulpfile.cjs
66
gulpfile.cjs
|
@ -1,15 +1,69 @@
|
||||||
const gulp = require("gulp");
|
const gulp = require("gulp");
|
||||||
const ts = require("gulp-typescript");
|
const ts = require("gulp-typescript");
|
||||||
|
const swc = require("gulp-swc");
|
||||||
const tsProject = ts.createProject("tsconfig.json");
|
const tsProject = ts.createProject("tsconfig.json");
|
||||||
|
const argv = require("yargs").argv;
|
||||||
|
const rimraf = require("rimraf");
|
||||||
|
const plumber = require("gulp-plumber");
|
||||||
|
|
||||||
// Task to compile TypeScript files
|
const swcOptions = {
|
||||||
|
jsc: {
|
||||||
|
parser: {
|
||||||
|
syntax: "typescript",
|
||||||
|
tsx: false,
|
||||||
|
decorators: true,
|
||||||
|
dynamicImport: true,
|
||||||
|
},
|
||||||
|
transform: {
|
||||||
|
react: {
|
||||||
|
runtime: "automatic",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
target: "es2022",
|
||||||
|
loose: false,
|
||||||
|
externalHelpers: false,
|
||||||
|
keepClassNames: true,
|
||||||
|
},
|
||||||
|
module: {
|
||||||
|
type: "es6",
|
||||||
|
strict: true,
|
||||||
|
strictMode: true,
|
||||||
|
lazy: false,
|
||||||
|
noInterop: false,
|
||||||
|
},
|
||||||
|
sourceMaps: "inline",
|
||||||
|
minify: false,
|
||||||
|
};
|
||||||
|
|
||||||
|
// Clean task to delete the dist directory
|
||||||
|
gulp.task("clean", (cb) => {
|
||||||
|
return rimraf.rimraf("dist").then(cb());
|
||||||
|
});
|
||||||
|
|
||||||
|
// Task to compile TypeScript files using SWC
|
||||||
gulp.task("scripts", () => {
|
gulp.task("scripts", () => {
|
||||||
return tsProject.src().pipe(tsProject()).js.pipe(gulp.dest("dist"));
|
if (argv.swc) {
|
||||||
|
return gulp
|
||||||
|
.src("src/**/*.ts")
|
||||||
|
.pipe(plumber()) // Prevent pipe breaking caused by errors
|
||||||
|
.pipe(swc(swcOptions))
|
||||||
|
.pipe(gulp.dest("dist"));
|
||||||
|
} else {
|
||||||
|
console.warn("[WARN] Using TSC compiler, will be slower than SWC");
|
||||||
|
return gulp
|
||||||
|
.src("src/**/*.ts")
|
||||||
|
.pipe(plumber()) // Prevent pipe breaking caused by errors
|
||||||
|
.pipe(tsProject())
|
||||||
|
.pipe(gulp.dest("dist"));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Task to copy HTML files
|
// Task to copy HTML files
|
||||||
gulp.task("copy-html", () => {
|
gulp.task("copy-html", () => {
|
||||||
return gulp.src("src/**/*.html").pipe(gulp.dest("dist"));
|
return gulp
|
||||||
|
.src("src/**/*.html")
|
||||||
|
.pipe(plumber()) // Prevent pipe breaking caused by errors
|
||||||
|
.pipe(gulp.dest("dist"));
|
||||||
});
|
});
|
||||||
|
|
||||||
// Task to copy other static assets (e.g., CSS, images)
|
// Task to copy other static assets (e.g., CSS, images)
|
||||||
|
@ -27,8 +81,12 @@ gulp.task("copy-assets", () => {
|
||||||
"src/**/*.gif",
|
"src/**/*.gif",
|
||||||
"src/**/*.svg",
|
"src/**/*.svg",
|
||||||
],{encoding:false})
|
],{encoding:false})
|
||||||
|
.pipe(plumber()) // Prevent pipe breaking caused by errors
|
||||||
.pipe(gulp.dest("dist"));
|
.pipe(gulp.dest("dist"));
|
||||||
});
|
});
|
||||||
|
|
||||||
// Default task to run all tasks
|
// Default task to run all tasks
|
||||||
gulp.task("default", gulp.series("scripts", "copy-html", "copy-assets"));
|
gulp.task(
|
||||||
|
"default",
|
||||||
|
gulp.series("clean", gulp.parallel("scripts", "copy-html", "copy-assets"))
|
||||||
|
);
|
||||||
|
|
10
package.json
10
package.json
|
@ -14,27 +14,31 @@
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@html-eslint/parser": "^0.27.0",
|
"@html-eslint/parser": "^0.27.0",
|
||||||
"@stylistic/eslint-plugin-js": "^2.8.0",
|
"@stylistic/eslint-plugin-js": "^2.8.0",
|
||||||
|
"@swc/core": "^1.7.26",
|
||||||
"@typescript-eslint/eslint-plugin": "^8.6.0",
|
"@typescript-eslint/eslint-plugin": "^8.6.0",
|
||||||
"@typescript-eslint/parser": "^8.6.0",
|
"@typescript-eslint/parser": "^8.6.0",
|
||||||
"compression": "^1.7.4",
|
"compression": "^1.7.4",
|
||||||
"eslint-plugin-html": "^8.1.1",
|
"eslint-plugin-html": "^8.1.1",
|
||||||
"express": "^4.19.2",
|
"express": "^4.19.2",
|
||||||
|
"gulp-swc": "^2.2.0",
|
||||||
"node-fetch": "^3.3.2",
|
"node-fetch": "^3.3.2",
|
||||||
|
"rimraf": "^6.0.1",
|
||||||
"ts-to-jsdoc": "^2.2.0"
|
"ts-to-jsdoc": "^2.2.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@eslint/js": "^9.10.0",
|
"@eslint/js": "^9.10.0",
|
||||||
"@html-eslint/eslint-plugin": "^0.25.0",
|
"@html-eslint/eslint-plugin": "^0.25.0",
|
||||||
|
"@stylistic/eslint-plugin": "^2.3.0",
|
||||||
"@types/compression": "^1.7.5",
|
"@types/compression": "^1.7.5",
|
||||||
"@types/eslint__js": "^8.42.3",
|
"@types/eslint__js": "^8.42.3",
|
||||||
"eslint-plugin-sonarjs": "^1.0.4",
|
|
||||||
"eslint-plugin-unicorn": "^55.0.0",
|
|
||||||
"@stylistic/eslint-plugin": "^2.3.0",
|
|
||||||
"@types/express": "^4.17.21",
|
"@types/express": "^4.17.21",
|
||||||
"@types/node-fetch": "^2.6.11",
|
"@types/node-fetch": "^2.6.11",
|
||||||
"eslint": "^8.57.1",
|
"eslint": "^8.57.1",
|
||||||
|
"eslint-plugin-sonarjs": "^1.0.4",
|
||||||
|
"eslint-plugin-unicorn": "^55.0.0",
|
||||||
"gulp": "^5.0.0",
|
"gulp": "^5.0.0",
|
||||||
"gulp-copy": "^5.0.0",
|
"gulp-copy": "^5.0.0",
|
||||||
|
"gulp-plumber": "^1.2.1",
|
||||||
"gulp-typescript": "^6.0.0-alpha.1",
|
"gulp-typescript": "^6.0.0-alpha.1",
|
||||||
"typescript": "^5.6.2",
|
"typescript": "^5.6.2",
|
||||||
"typescript-eslint": "^8.6.0"
|
"typescript-eslint": "^8.6.0"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue