mirror of
https://github.com/withastro/astro.git
synced 2025-01-13 22:11:20 -05:00
1ea0a25b94
* feat: add multiple cdn * add multiple cdn test * assetsPrefix not empty string * add changeset * simplify code * change docs * replace getFileExtension with node path.extname * Adapt node extname * multiple image test * wip space * update docs * update docs, assetsPrefix type * update docs * update docs * chore: update types and rename to `fallback` * enhance changelog * change docs * update change defaultAeestsPrefix to fallback key test * move utility to a new to avoid importing `node:path` inside vite plugins * Update packages/astro/src/@types/astro.ts Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca> * Apply suggestions from code review Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca> * chore: address Bjorn's comments * kill the variable * kill the variable /2 * Fix CI fail * Apply suggestions from code review Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca> * uniform code sample * add `.` string for fit getAssetsPrefix * Fix extension function --------- Co-authored-by: Emanuele Stoppa <my.burning@gmail.com> Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca> Co-authored-by: bluwy <bjornlu.dev@gmail.com> Co-authored-by: Erika <3019731+Princesseuh@users.noreply.github.com>
892 B
892 B
@astrojs/internal-helpers | astro |
---|---|
minor | minor |
Adds the option to pass an object to build.assetsPrefix
. This allows for the use of multiple CDN prefixes based on the target file type.
When passing an object to build.assetsPrefix
, you must also specify a fallback
domain to be used for all other file types not specified.
Specify a file extension as the key (e.g. 'js', 'png') and the URL serving your assets of that file type as the value:
// astro.config.mjs
import { defineConfig } from "astro/config"
export default defineConfig({
build: {
assetsPrefix: {
'js': "https://js.cdn.example.com",
'mjs': "https://js.cdn.example.com", // if you have .mjs files, you must add a new entry like this
'png': "https://images.cdn.example.com",
'fallback': "https://generic.cdn.example.com"
}
}
})