Skip to content

Commit 6058685

Browse files
authored
Fix base handling (#35)
1 parent 4c2f05f commit 6058685

File tree

1 file changed

+6
-3
lines changed
  • packages/core/src/plugins

1 file changed

+6
-3
lines changed

packages/core/src/plugins/api.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ export function apiPlugin(options = {}) {
1717
let isBuild
1818
/** @type {string} */
1919
let projectRoot
20+
/** @type {string} */
21+
let projectBase = '/'
2022

2123
// used for final import map generation
2224
/** @type {Map<string, string>} */
@@ -42,6 +44,7 @@ export function apiPlugin(options = {}) {
4244
},
4345
configResolved(c) {
4446
projectRoot = c.root
47+
projectBase = c.base
4548
},
4649
/** @type {import('../..').Api} */
4750
api: {
@@ -71,7 +74,7 @@ export function apiPlugin(options = {}) {
7174
attrs.push({
7275
type: 'static',
7376
name: isComponent ? '_why?.src' : 'src',
74-
value: options.defaultSrc || '/' + templateDefaultId
77+
value: options.defaultSrc || projectBase + templateDefaultId
7578
})
7679
if (isBuild) {
7780
hashToEntryIds.set(hash, entryId)
@@ -84,7 +87,7 @@ export function apiPlugin(options = {}) {
8487
attrs.push({
8588
type: 'static',
8689
name: isComponent ? '_why?.id' : 'data-why-id',
87-
value: `/@id/__${entryId}`
90+
value: `${projectBase}@id/__${entryId}`
8891
})
8992
}
9093
if (source) {
@@ -117,7 +120,7 @@ export function apiPlugin(options = {}) {
117120
type: 'dynamic',
118121
name: 'src',
119122
value: `_why?.src || ${JSON.stringify(
120-
options.defaultSrc || '/' + templateDefaultId
123+
options.defaultSrc || projectBase + templateDefaultId
121124
)}`
122125
},
123126
{

0 commit comments

Comments
 (0)