mirror of
https://github.com/ThatGuySam/doesitarm.git
synced 2026-05-18 06:44:46 -07:00
Try PUBLIC_URL first
This commit is contained in:
parent
993528c9cc
commit
5eeaf42e4d
1 changed files with 12 additions and 6 deletions
|
|
@ -5,6 +5,18 @@ export function getSiteUrl () {
|
|||
const hasImportMeta = typeof import.meta !== 'undefined'
|
||||
const hasImportMetaEnv = hasImportMeta && typeof import.meta.env !== 'undefined'
|
||||
|
||||
// Try PUBLIC_URL
|
||||
if ( typeof process.env.PUBLIC_URL !== 'undefined' ) {
|
||||
console.log('Has env.PUBLIC_URL')
|
||||
return process.env.PUBLIC_URL
|
||||
}
|
||||
|
||||
if ( hasImportMetaEnv && typeof import.meta.env.PUBLIC_URL !== 'undefined' ) {
|
||||
console.log('Has PUBLIC_URL')
|
||||
return import.meta.env.PUBLIC_URL
|
||||
}
|
||||
|
||||
|
||||
// Try process.env.URL
|
||||
if ( typeof process.env.URL !== 'undefined' ) {
|
||||
console.log('Has env.URL')
|
||||
|
|
@ -23,11 +35,5 @@ export function getSiteUrl () {
|
|||
return import.meta.env.URL
|
||||
}
|
||||
|
||||
// Try PUBLIC_URL
|
||||
if ( hasImportMetaEnv && typeof import.meta.env.PUBLIC_URL !== 'undefined' ) {
|
||||
console.log('Has PUBLIC_URL')
|
||||
return import.meta.env.PUBLIC_URL
|
||||
}
|
||||
|
||||
throw new Error('Could not find site URL')
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue