@wroud/vite-plugin-ssg
Version:
A Vite plugin for static site generation (SSG) with React. Renders React applications to static HTML for faster load times and improved SEO.
13 lines • 563 B
JavaScript
export function changePathExt(path, ext) {
const [pathPart, queryPart] = path.split("?");
const queryString = queryPart ? `?${queryPart}` : "";
const lastDotIndex = pathPart.lastIndexOf(".");
// If no dot found or dot is at the beginning (like in .env), treat as no extension
if (lastDotIndex <= 0) {
return pathPart + ext + queryString;
}
// Remove existing extension and add new one
const basename = pathPart.substring(0, lastDotIndex);
return basename + ext + queryString;
}
//# sourceMappingURL=changePathExt.js.map