Skip to content

Commit

Permalink
Fix base handling (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
bx-shef authored Dec 4, 2024
1 parent 4c2f05f commit 6058685
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions packages/core/src/plugins/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ export function apiPlugin(options = {}) {
let isBuild
/** @type {string} */
let projectRoot
/** @type {string} */
let projectBase = '/'

// used for final import map generation
/** @type {Map<string, string>} */
Expand All @@ -42,6 +44,7 @@ export function apiPlugin(options = {}) {
},
configResolved(c) {
projectRoot = c.root
projectBase = c.base
},
/** @type {import('../..').Api} */
api: {
Expand Down Expand Up @@ -71,7 +74,7 @@ export function apiPlugin(options = {}) {
attrs.push({
type: 'static',
name: isComponent ? '_why?.src' : 'src',
value: options.defaultSrc || '/' + templateDefaultId
value: options.defaultSrc || projectBase + templateDefaultId
})
if (isBuild) {
hashToEntryIds.set(hash, entryId)
Expand All @@ -84,7 +87,7 @@ export function apiPlugin(options = {}) {
attrs.push({
type: 'static',
name: isComponent ? '_why?.id' : 'data-why-id',
value: `/@id/__${entryId}`
value: `${projectBase}@id/__${entryId}`
})
}
if (source) {
Expand Down Expand Up @@ -117,7 +120,7 @@ export function apiPlugin(options = {}) {
type: 'dynamic',
name: 'src',
value: `_why?.src || ${JSON.stringify(
options.defaultSrc || '/' + templateDefaultId
options.defaultSrc || projectBase + templateDefaultId
)}`
},
{
Expand Down

0 comments on commit 6058685

Please sign in to comment.