Skip to content

Commit

Permalink
fix: use legacy property publicPath for the assets url.
Browse files Browse the repository at this point in the history
  • Loading branch information
wattanx committed Aug 31, 2024
1 parent eeef3b6 commit a663637
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
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

0 comments on commit a663637

Please sign in to comment.