Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions packages/astro/src/assets/fonts/vite-plugin-fonts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@ import { readFile } from 'node:fs/promises';
import { isAbsolute } from 'node:path';
import { fileURLToPath } from 'node:url';
import { bold } from 'kleur/colors';
import type { Plugin } from 'vite';
import type { Plugin, RunnableDevEnvironment } from 'vite';
import { getAlgorithm, shouldTrackCspHashes } from '../../core/csp/common.js';
import { generateCspDigest } from '../../core/encryption.js';
import { collectErrorMetadata } from '../../core/errors/dev/utils.js';
import { AstroError, AstroErrorData, isAstroError } from '../../core/errors/index.js';
import type { Logger } from '../../core/logger/core.js';
import { formatErrorMessage } from '../../core/messages.js';
import { getRunnableEnvironment } from '../../core/module-loader/index.js';
import { appendForwardSlash, joinPaths, prependForwardSlash } from '../../core/path.js';
import { getClientOutputDirectory } from '../../prerender/utils.js';
import type { AstroSettings } from '../../types/astro.js';
Expand Down Expand Up @@ -230,11 +229,12 @@ export function fontsPlugin({ settings, sync, logger }: Options): Plugin {
}
},
async configureServer(server) {
const environment = getRunnableEnvironment(server);
await initialize({
// In dev, we cache fonts data in .astro so it can be easily inspected and cleared
cacheDir: new URL(CACHE_DIR, settings.dotAstroDir),
modResolver: createDevServerRemoteFontProviderModResolver({ environment }),
modResolver: createDevServerRemoteFontProviderModResolver({
environment: server.environments.astro as RunnableDevEnvironment,
}),
cssRenderer: createMinifiableCssRenderer({ minify: false }),
urlResolver: createDevUrlResolver({ base: baseUrl }),
createHashResolver: (dependencies) =>
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/content/types-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export async function createContentTypesGenerator({
await reloadContentConfigObserver({
fs,
settings,
environment: viteServer.environments.content as RunnableDevEnvironment,
environment: viteServer.environments.astro as RunnableDevEnvironment,
});
return { shouldGenerateTypes: true };
}
Expand Down
10 changes: 1 addition & 9 deletions packages/astro/src/content/vite-plugin-content-imports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,6 @@ export function astroContentImportPlugin({
name: 'astro:content-imports',
config(_config, env) {
shouldEmitFile = env.command === 'build';
return {
environments: {
content: {
// This is all that's needed to create a new RunnableDevEnvironment
dev: {},
},
},
};
},
async buildStart() {
// Get symlinks once at build start
Expand Down Expand Up @@ -172,7 +164,7 @@ export const _internal = {
await reloadContentConfigObserver({
fs,
settings,
environment: viteServer.environments.content as RunnableDevEnvironment,
environment: viteServer.environments.astro as RunnableDevEnvironment,
});
}

Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/core/app/entrypoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const manifest: SSRManifest = Object.assign(serializedManifest, {
renderers,
actions: () => import('virtual:astro:actions/entrypoint'),
middleware: () => import('virtual:astro:middleware'),
sessionDriver: () => import('virtual:astro:session-driver'),
sessionDriver: () => null,
routes,
});

Expand Down
6 changes: 6 additions & 0 deletions packages/astro/src/core/create-vite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,12 @@ export async function createVite(
external: [...(command === 'dev' ? ONLY_DEV_EXTERNAL : []), ...astroPkgsConfig.ssr.external],
},
build: { assetsDir: settings.config.build.assets },
environments: {
astro: {
// This is all that's needed to create a new RunnableDevEnvironment
dev: {},
},
},
};

// If the user provides a custom assets prefix, make sure assets handled by Vite
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @ts-check
import cloudflare from '@astrojs/cloudflare';
import { defineConfig, envField } from 'astro/config';
import { defineConfig, envField, fontProviders } from 'astro/config';

import mdx from '@astrojs/mdx';
import { fileURLToPath } from 'node:url';
Expand Down Expand Up @@ -36,5 +36,12 @@ export default defineConfig({
BAR: envField.string({ context: 'client', access: 'public' }),
SECRET: envField.string({ context: 'server', access: 'secret' }),
}
},
experimental: {
fonts: [{
provider: fontProviders.google(),
name: "Roboto",
cssVariable: "--font-roboto"
}]
}
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,8 @@ const markdownContent = `
# heading 1
hello
## heading 2
![image](./image.png)
![image 2](https://example.com/image.png)
![image](/image.png)
![image 2](https://placehold.co/100x50)
`

const increment = defineCollection({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
---
export const prerender = false;

import { getCollection, getEntry, render } from 'astro:content';
import Hello from '../components/Hello.tsx';
import Island from '../components/Island.astro';
import { Font } from 'astro:assets';


const workerRuntime = globalThis.navigator?.userAgent
const blog = await getCollection('blog');
Expand All @@ -11,9 +14,15 @@ const dogs = await getCollection('dogs');
const increment = await getEntry('increment', 'value');
const { Content } = await render(increment);
---
<style>
body {
font-family: var(--font-roboto);
}
</style>
<html>
<head>
<meta charset="utf-8" />
<Font cssVariable='--font-roboto' preload />
<title>Index</title>
</head>
<body>
Expand Down Expand Up @@ -55,9 +64,7 @@ const { Content } = await render(increment);
<li><a href={`/blog/${post.id}`}>{ post.data?.title }</a></li>
))}
</ul>




</body>
</html>


Original file line number Diff line number Diff line change
@@ -1,24 +1,15 @@
{
"compatibility_date": "2025-05-21",
"compatibility_date": "2025-10-30",
"compatibility_flags": [
"nodejs_compat",
"global_fetch_strictly_public"
],
"name": "astro-cloudflare-custom-entryfile",
"main": "dist/_worker.js/index.js",
"main": "@astrojs/cloudflare/entrypoints/server",
"assets": {
"directory": "./dist",
"binding": "ASSETS"
},
"images": {
"binding": "IMAGES"
},
"observability": {
"logs": {
"enabled": true,
"head_sampling_rate": 1,
"invocation_logs": true,
"persist": true
}
}
}
}
Loading