Skip to content
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

Fix base handling #35

Merged
merged 4 commits into from
Dec 4, 2024
Merged
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
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
Loading