mirror of
https://github.com/withastro/astro.git
synced 2025-03-17 23:11:29 -05:00
fix: do not use fs mock
This commit is contained in:
parent
d835645adf
commit
5bee7ff39b
2 changed files with 5 additions and 7 deletions
packages/astro/src
|
@ -133,7 +133,7 @@ export async function createVite(
|
|||
// the build to run very slow as the filewatcher is triggered often.
|
||||
mode !== 'build' && vitePluginAstroServer({ settings, logger, fs }),
|
||||
envVitePlugin({ settings }),
|
||||
astroEnv({ settings, mode, fs, sync }),
|
||||
astroEnv({ settings, mode, sync }),
|
||||
markdownVitePlugin({ settings, logger }),
|
||||
htmlVitePlugin(),
|
||||
mdxVitePlugin(),
|
||||
|
|
10
packages/astro/src/env/vite-plugin-env.ts
vendored
10
packages/astro/src/env/vite-plugin-env.ts
vendored
|
@ -1,4 +1,4 @@
|
|||
import type fsMod from 'node:fs';
|
||||
import { readFileSync } from 'node:fs';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { type Plugin, loadEnv } from 'vite';
|
||||
import type { AstroSettings } from '../@types/astro.js';
|
||||
|
@ -15,11 +15,10 @@ import { getEnvFieldType, validateEnvVariable } from './validators.js';
|
|||
interface AstroEnvPluginParams {
|
||||
settings: AstroSettings;
|
||||
mode: 'dev' | 'build' | string;
|
||||
fs: typeof fsMod;
|
||||
sync: boolean;
|
||||
}
|
||||
|
||||
export function astroEnv({ settings, mode, fs, sync }: AstroEnvPluginParams): Plugin | undefined {
|
||||
export function astroEnv({ settings, mode, sync }: AstroEnvPluginParams): Plugin | undefined {
|
||||
if (sync) {
|
||||
return;
|
||||
}
|
||||
|
@ -49,7 +48,7 @@ export function astroEnv({ settings, mode, fs, sync }: AstroEnvPluginParams): Pl
|
|||
});
|
||||
|
||||
templates = {
|
||||
...getTemplates(schema, fs, validatedVariables),
|
||||
...getTemplates(schema, validatedVariables),
|
||||
internal: `export const schema = ${JSON.stringify(schema)};`,
|
||||
};
|
||||
},
|
||||
|
@ -126,11 +125,10 @@ function validatePublicVariables({
|
|||
|
||||
function getTemplates(
|
||||
schema: EnvSchema,
|
||||
fs: typeof fsMod,
|
||||
validatedVariables: ReturnType<typeof validatePublicVariables>,
|
||||
) {
|
||||
let client = '';
|
||||
let server = fs.readFileSync(MODULE_TEMPLATE_URL, 'utf-8');
|
||||
let server = readFileSync(MODULE_TEMPLATE_URL, 'utf-8');
|
||||
let onSetGetEnv = '';
|
||||
|
||||
for (const { key, value, context } of validatedVariables) {
|
||||
|
|
Loading…
Add table
Reference in a new issue