full site update
This commit is contained in:
49
node_modules/astro/dist/core/create-vite.js
generated
vendored
49
node_modules/astro/dist/core/create-vite.js
generated
vendored
@@ -1,6 +1,6 @@
|
||||
import nodeFs from "node:fs";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import glob from "fast-glob";
|
||||
import { convertPathToPattern } from "tinyglobby";
|
||||
import * as vite from "vite";
|
||||
import { crawlFrameworkPkgs } from "vitefu";
|
||||
import { vitePluginActions, vitePluginUserActions } from "../actions/plugins.js";
|
||||
@@ -12,23 +12,25 @@ import {
|
||||
astroContentImportPlugin,
|
||||
astroContentVirtualModPlugin
|
||||
} from "../content/index.js";
|
||||
import { createEnvLoader } from "../env/env-loader.js";
|
||||
import { astroEnv } from "../env/vite-plugin-env.js";
|
||||
import { importMetaEnv } from "../env/vite-plugin-import-meta-env.js";
|
||||
import astroInternationalization from "../i18n/vite-plugin-i18n.js";
|
||||
import astroVirtualManifestPlugin from "../manifest/virtual-module.js";
|
||||
import astroPrefetch from "../prefetch/vite-plugin-prefetch.js";
|
||||
import astroDevToolbar from "../toolbar/vite-plugin-dev-toolbar.js";
|
||||
import astroTransitions from "../transitions/vite-plugin-transitions.js";
|
||||
import astroVitePlugin from "../vite-plugin-astro/index.js";
|
||||
import astroPostprocessVitePlugin from "../vite-plugin-astro-postprocess/index.js";
|
||||
import { vitePluginAstroServer } from "../vite-plugin-astro-server/index.js";
|
||||
import astroVitePlugin from "../vite-plugin-astro/index.js";
|
||||
import configAliasVitePlugin from "../vite-plugin-config-alias/index.js";
|
||||
import envVitePlugin from "../vite-plugin-env/index.js";
|
||||
import vitePluginFileURL from "../vite-plugin-fileurl/index.js";
|
||||
import astroHeadPlugin from "../vite-plugin-head/index.js";
|
||||
import astroHmrReloadPlugin from "../vite-plugin-hmr-reload/index.js";
|
||||
import htmlVitePlugin from "../vite-plugin-html/index.js";
|
||||
import astroIntegrationsContainerPlugin from "../vite-plugin-integrations-container/index.js";
|
||||
import astroLoadFallbackPlugin from "../vite-plugin-load-fallback/index.js";
|
||||
import markdownVitePlugin from "../vite-plugin-markdown/index.js";
|
||||
import mdxVitePlugin from "../vite-plugin-mdx/index.js";
|
||||
import astroScannerPlugin from "../vite-plugin-scanner/index.js";
|
||||
import astroScriptsPlugin from "../vite-plugin-scripts/index.js";
|
||||
import astroScriptsPageSSRPlugin from "../vite-plugin-scripts/page-ssr.js";
|
||||
@@ -57,10 +59,10 @@ const ONLY_DEV_EXTERNAL = [
|
||||
// Imported by `astro:transitions` -> packages/astro/src/runtime/server/transition.ts
|
||||
"cssesc"
|
||||
];
|
||||
async function createVite(commandConfig, { settings, logger, mode, command, fs = nodeFs, sync }) {
|
||||
async function createVite(commandConfig, { settings, logger, mode, command, fs = nodeFs, sync, routesList, manifest }) {
|
||||
const astroPkgsConfig = await crawlFrameworkPkgs({
|
||||
root: fileURLToPath(settings.config.root),
|
||||
isBuild: mode === "build",
|
||||
isBuild: command === "build",
|
||||
viteUserConfig: settings.config.vite,
|
||||
isFrameworkPkgByJson(pkgJson) {
|
||||
if (pkgJson?.astro?.external === true) {
|
||||
@@ -82,10 +84,16 @@ async function createVite(commandConfig, { settings, logger, mode, command, fs =
|
||||
}
|
||||
}
|
||||
});
|
||||
const srcDirPattern = glob.convertPathToPattern(fileURLToPath(settings.config.srcDir));
|
||||
const srcDirPattern = convertPathToPattern(fileURLToPath(settings.config.srcDir));
|
||||
const envLoader = createEnvLoader(
|
||||
mode,
|
||||
settings.config,
|
||||
settings.config.experimental.rawEnvValues
|
||||
);
|
||||
const commonConfig = {
|
||||
// Tell Vite not to combine config from vite.config.js with our provided inline config
|
||||
configFile: false,
|
||||
mode,
|
||||
cacheDir: fileURLToPath(new URL("./node_modules/.vite/", settings.config.root)),
|
||||
// using local caches allows Astro to be used in monorepos, etc.
|
||||
clearScreen: false,
|
||||
@@ -98,29 +106,30 @@ async function createVite(commandConfig, { settings, logger, mode, command, fs =
|
||||
exclude: ["astro", "node-fetch"]
|
||||
},
|
||||
plugins: [
|
||||
astroVirtualManifestPlugin({ manifest }),
|
||||
configAliasVitePlugin({ settings }),
|
||||
astroLoadFallbackPlugin({ fs, root: settings.config.root }),
|
||||
astroVitePlugin({ settings, logger }),
|
||||
astroScriptsPlugin({ settings }),
|
||||
// The server plugin is for dev only and having it run during the build causes
|
||||
// the build to run very slow as the filewatcher is triggered often.
|
||||
mode !== "build" && vitePluginAstroServer({ settings, logger, fs }),
|
||||
envVitePlugin({ settings, logger }),
|
||||
astroEnv({ settings, mode, fs, sync }),
|
||||
command === "dev" && vitePluginAstroServer({ settings, logger, fs, routesList, manifest }),
|
||||
// manifest is only required in dev mode, where it gets created before a Vite instance is created, and get passed to this function
|
||||
importMetaEnv({ envLoader }),
|
||||
astroEnv({ settings, sync, envLoader }),
|
||||
markdownVitePlugin({ settings, logger }),
|
||||
htmlVitePlugin(),
|
||||
mdxVitePlugin(),
|
||||
astroPostprocessVitePlugin(),
|
||||
astroIntegrationsContainerPlugin({ settings, logger }),
|
||||
astroScriptsPageSSRPlugin({ settings }),
|
||||
astroHeadPlugin(),
|
||||
astroScannerPlugin({ settings, logger }),
|
||||
astroScannerPlugin({ settings, logger, routesList }),
|
||||
astroContentVirtualModPlugin({ fs, settings }),
|
||||
astroContentImportPlugin({ fs, settings, logger }),
|
||||
astroContentAssetPropagationPlugin({ mode, settings }),
|
||||
astroContentAssetPropagationPlugin({ settings }),
|
||||
vitePluginMiddleware({ settings }),
|
||||
vitePluginSSRManifest(),
|
||||
astroAssetsPlugin({ settings, logger, mode }),
|
||||
astroAssetsPlugin({ fs, settings, sync, logger }),
|
||||
astroPrefetch({ settings }),
|
||||
astroTransitions({ settings }),
|
||||
astroDevToolbar({ settings, logger }),
|
||||
@@ -128,8 +137,9 @@ async function createVite(commandConfig, { settings, logger, mode, command, fs =
|
||||
astroInternationalization({ settings }),
|
||||
vitePluginActions({ fs, settings }),
|
||||
vitePluginUserActions({ settings }),
|
||||
settings.config.experimental.serverIslands && vitePluginServerIslands({ settings }),
|
||||
astroContainer()
|
||||
vitePluginServerIslands({ settings, logger }),
|
||||
astroContainer(),
|
||||
astroHmrReloadPlugin()
|
||||
],
|
||||
publicDir: fileURLToPath(settings.config.publicDir),
|
||||
root: fileURLToPath(settings.config.root),
|
||||
@@ -144,7 +154,7 @@ async function createVite(commandConfig, { settings, logger, mode, command, fs =
|
||||
// disable HMR for test
|
||||
watch: {
|
||||
// Prevent watching during the build to speed it up
|
||||
ignored: mode === "build" ? ["**"] : void 0
|
||||
ignored: command === "build" ? ["**"] : void 0
|
||||
}
|
||||
},
|
||||
resolve: {
|
||||
@@ -158,7 +168,7 @@ async function createVite(commandConfig, { settings, logger, mode, command, fs =
|
||||
{
|
||||
// Typings are imported from 'astro' (e.g. import { Type } from 'astro')
|
||||
find: /^astro$/,
|
||||
replacement: fileURLToPath(new URL("../@types/astro.js", import.meta.url))
|
||||
replacement: fileURLToPath(new URL("../types/public/index.js", import.meta.url))
|
||||
},
|
||||
{
|
||||
find: "astro:middleware",
|
||||
@@ -173,13 +183,12 @@ async function createVite(commandConfig, { settings, logger, mode, command, fs =
|
||||
replacement: "astro/components"
|
||||
}
|
||||
],
|
||||
conditions: ["astro"],
|
||||
// Astro imports in third-party packages should use the same version as root
|
||||
dedupe: ["astro"]
|
||||
},
|
||||
ssr: {
|
||||
noExternal: [...ALWAYS_NOEXTERNAL, ...astroPkgsConfig.ssr.noExternal],
|
||||
external: [...mode === "dev" ? ONLY_DEV_EXTERNAL : [], ...astroPkgsConfig.ssr.external]
|
||||
external: [...command === "dev" ? ONLY_DEV_EXTERNAL : [], ...astroPkgsConfig.ssr.external]
|
||||
},
|
||||
build: { assetsDir: settings.config.build.assets }
|
||||
};
|
||||
|
Reference in New Issue
Block a user