🎉 initiate project *astro_rewrite*
This commit is contained in:
parent
ffd4d5e86c
commit
2ba37bfbe3
8658 changed files with 2268794 additions and 2538 deletions
45
node_modules/astro/dist/vite-plugin-scanner/index.js
generated
vendored
Normal file
45
node_modules/astro/dist/vite-plugin-scanner/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
import { normalizePath } from "vite";
|
||||
import { isEndpoint, isPage } from "../core/util.js";
|
||||
import { getPrerenderDefault } from "../prerender/utils.js";
|
||||
import { scan } from "./scan.js";
|
||||
function astroScannerPlugin({ settings }) {
|
||||
return {
|
||||
name: "astro:scanner",
|
||||
enforce: "post",
|
||||
async transform(code, id, options) {
|
||||
if (!(options == null ? void 0 : options.ssr))
|
||||
return;
|
||||
const filename = normalizePath(id);
|
||||
let fileURL;
|
||||
try {
|
||||
fileURL = new URL(`file://${filename}`);
|
||||
} catch (e) {
|
||||
return;
|
||||
}
|
||||
const fileIsPage = isPage(fileURL, settings);
|
||||
const fileIsEndpoint = isEndpoint(fileURL, settings);
|
||||
if (!(fileIsPage || fileIsEndpoint))
|
||||
return;
|
||||
const defaultPrerender = getPrerenderDefault(settings.config);
|
||||
const pageOptions = await scan(code, id, settings.config.output === "hybrid");
|
||||
if (typeof pageOptions.prerender === "undefined") {
|
||||
pageOptions.prerender = defaultPrerender;
|
||||
}
|
||||
const { meta = {} } = this.getModuleInfo(id) ?? {};
|
||||
return {
|
||||
code,
|
||||
map: null,
|
||||
meta: {
|
||||
...meta,
|
||||
astro: {
|
||||
...meta.astro ?? { hydratedComponents: [], clientOnlyComponents: [], scripts: [] },
|
||||
pageOptions
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
export {
|
||||
astroScannerPlugin as default
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue