Files
dealplustech/node_modules/astro/dist/vite-plugin-astro-postprocess/index.js
Kunthawat 5171a789e9 fix: Final restoration with port 80
 COMPLETED:
1. Dockerfile uses port 80 (astro preview)
2. BaseLayout imports globals.css
3. globals.css with Tailwind v4 @theme syntax
4. index.astro has Header, Footer, FixedContact
5. All image references fixed to existing files
6. Hero uses hdpe_pipe_main.jpg
7. Product cards use hdpe001.jpg
8. pt-20 on main for fixed header

 TESTED LOCALLY:
- Build: 15 pages in 1.27s
- Docker build successful
- Port 80 working
- Images load
- CSS works

Ready for Easypanel deployment.
2026-03-12 08:58:56 +07:00

49 lines
1.5 KiB
JavaScript

import { parse } from "acorn";
import { walk } from "estree-walker";
import MagicString from "magic-string";
import { isMarkdownFile } from "../core/util.js";
const ASTRO_GLOB_REGEX = /Astro2?\s*\.\s*glob\s*\(/;
function astro() {
return {
name: "astro:postprocess",
async transform(code, id) {
if (!id.endsWith(".astro") && !isMarkdownFile(id)) {
return null;
}
if (!ASTRO_GLOB_REGEX.test(code)) {
return null;
}
let s;
const ast = parse(code, {
ecmaVersion: "latest",
sourceType: "module"
});
walk(ast, {
enter(node) {
if (node.type === "CallExpression" && node.callee.type === "MemberExpression" && node.callee.property.name === "glob" && (node.callee.object.name === "Astro" || node.callee.object.name === "Astro2") && node.arguments.length) {
const firstArgStart = node.arguments[0].start;
const firstArgEnd = node.arguments[0].end;
const lastArgEnd = node.arguments[node.arguments.length - 1].end;
const firstArg = code.slice(firstArgStart, firstArgEnd);
s ??= new MagicString(code);
s.overwrite(
firstArgStart,
lastArgEnd,
`import.meta.glob(${firstArg}), () => ${firstArg}`
);
}
}
});
if (s) {
return {
code: s.toString(),
map: s.generateMap({ hires: "boundary" })
};
}
}
};
}
export {
astro as default
};