possible optimizations
This commit is contained in:
parent
44ca1ace9a
commit
ef77d921be
4 changed files with 71 additions and 0 deletions
|
|
@ -3,9 +3,14 @@ import type { NextConfig } from "next";
|
|||
const nextConfig: NextConfig = {
|
||||
output: "export",
|
||||
distDir: "dist",
|
||||
compress: true,
|
||||
images: {
|
||||
unoptimized: true,
|
||||
},
|
||||
experimental: {
|
||||
inlineCss: true,
|
||||
optimizePackageImports: ["lucide-react", "gsap"],
|
||||
},
|
||||
};
|
||||
|
||||
export default nextConfig;
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
"scripts": {
|
||||
"dev": "next dev",
|
||||
"build": "next build",
|
||||
"postbuild": "node scripts/cleanup-legacy.js",
|
||||
"start": "next start",
|
||||
"lint": "next lint"
|
||||
},
|
||||
|
|
@ -19,6 +20,12 @@
|
|||
"tailwind-merge": "^3.5.0",
|
||||
"tailwindcss": "^4.2.4"
|
||||
},
|
||||
"browserslist": [
|
||||
"last 2 Chrome versions",
|
||||
"last 2 Firefox versions",
|
||||
"last 2 Safari versions",
|
||||
"last 2 Edge versions"
|
||||
],
|
||||
"devDependencies": {
|
||||
"@tailwindcss/postcss": "^4.2.4",
|
||||
"@types/node": "^24.12.2",
|
||||
|
|
|
|||
57
scripts/cleanup-legacy.js
Normal file
57
scripts/cleanup-legacy.js
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
import { readFileSync, writeFileSync, unlinkSync, readdirSync, statSync } from "fs";
|
||||
import { join } from "path";
|
||||
|
||||
const distDir = "./dist";
|
||||
|
||||
function walk(dir, callback) {
|
||||
for (const entry of readdirSync(dir)) {
|
||||
const fullPath = join(dir, entry);
|
||||
const stats = statSync(fullPath);
|
||||
if (stats.isDirectory()) {
|
||||
walk(fullPath, callback);
|
||||
} else {
|
||||
callback(fullPath, stats);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Remove noModule script tags from all HTML files
|
||||
let htmlCount = 0;
|
||||
walk(distDir, (filePath) => {
|
||||
if (filePath.endsWith(".html")) {
|
||||
let content = readFileSync(filePath, "utf-8");
|
||||
const before = content.length;
|
||||
// Remove both <script ... noModule=""> and self-closing variants
|
||||
content = content.replace(/<script[^>]*\snoModule[^>]*>(?:[^<]*(?:<(?!\/script>)[^<]*)*)?<\/script>/gi, "");
|
||||
content = content.replace(/<script[^>]*\snoModule[^>]*\/>/gi, "");
|
||||
if (content.length !== before) {
|
||||
writeFileSync(filePath, content);
|
||||
htmlCount++;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (htmlCount > 0) {
|
||||
console.log(`Cleaned noModule scripts from ${htmlCount} HTML files`);
|
||||
}
|
||||
|
||||
// Remove core-js polyfill chunks
|
||||
let removedCount = 0;
|
||||
walk(distDir, (filePath) => {
|
||||
if (filePath.endsWith(".js")) {
|
||||
try {
|
||||
const content = readFileSync(filePath, "utf-8");
|
||||
if (content.includes('"zloirock"') || content.includes("core-js")) {
|
||||
unlinkSync(filePath);
|
||||
console.log("Removed legacy polyfill:", filePath);
|
||||
removedCount++;
|
||||
}
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (removedCount === 0) {
|
||||
console.log("No legacy polyfills found to remove");
|
||||
}
|
||||
|
|
@ -17,6 +17,7 @@ const inter = Inter({
|
|||
weight: ["400", "500", "600"],
|
||||
variable: "--font-inter",
|
||||
display: "swap",
|
||||
preload: false,
|
||||
});
|
||||
|
||||
const ibmPlexMono = IBM_Plex_Mono({
|
||||
|
|
@ -24,6 +25,7 @@ const ibmPlexMono = IBM_Plex_Mono({
|
|||
weight: ["400", "500"],
|
||||
variable: "--font-ibm-plex-mono",
|
||||
display: "swap",
|
||||
preload: false,
|
||||
});
|
||||
|
||||
export const metadata: Metadata = {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue