Skip to content

fix: use legacy property publicPath for the assets url. #1303

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
16 changes: 16 additions & 0 deletions packages/bridge-schema/src/config/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,22 @@ export default defineUntypedSchema({
buildAssetsDir: {
$resolve: val => val || process.env.NUXT_APP_BUILD_ASSETS_DIR || '/_nuxt/'
},
/**
* An absolute URL to serve the public folder from (production-only).
*
* For example:
* @example
* ```ts
* export default defineNuxtConfig({
* app: {
* cdnURL: 'https://mycdn.org/'
* }
* })
* ```
*/
cdnURL: {
$resolve: async (val, get) => (await get('dev')) ? '' : (process.env.NUXT_APP_CDN_URL ?? val) || ''
},
/**
* The folder name for the built site assets, relative to `baseURL` (or `cdnURL` if set).
* @deprecated - use `buildAssetsDir` instead
Expand Down
4 changes: 4 additions & 0 deletions packages/bridge/src/nitro.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,14 @@ export async function setupNitroBridge () {
}

// Handle legacy property name `assetsPath`
// @ts-expect-error `assetsPath` is legacy options
nuxt.options.app.buildAssetsDir = nuxt.options.app.buildAssetsDir || nuxt.options.app.assetsPath
// @ts-expect-error `assetsPath` is legacy options
nuxt.options.app.assetsPath = nuxt.options.app.buildAssetsDir
nuxt.options.app.baseURL = nuxt.options.app.baseURL || (nuxt.options.app as any).basePath
nuxt.options.app.cdnURL = nuxt.options.app.cdnURL || ''
// @ts-expect-error `publicPath` is legacy options
nuxt.options.build.publicPath = nuxt.options.app.cdnURL || nuxt.options.build.publicPath

// Extract publicConfig and app
const publicConfig = nuxt.options.publicRuntimeConfig
Expand Down