mirror of
https://github.com/ThatGuySam/doesitarm.git
synced 2026-05-15 06:35:20 -07:00
Handle import.meta.env undefined
This commit is contained in:
parent
e333fe7959
commit
023201a5f2
1 changed files with 5 additions and 2 deletions
|
|
@ -2,6 +2,9 @@ export function getSiteUrl () {
|
|||
|
||||
// console.log( 'import.meta.site', import.meta.env )
|
||||
|
||||
const hasImportMeta = typeof import.meta !== 'undefined'
|
||||
const hasImportMetaEnv = hasImportMeta && typeof import.meta.env !== 'undefined'
|
||||
|
||||
// Try process.env.URL
|
||||
if ( typeof process.env.URL !== 'undefined' ) {
|
||||
console.log('Has env.URL')
|
||||
|
|
@ -15,13 +18,13 @@ export function getSiteUrl () {
|
|||
}
|
||||
|
||||
// Try URL
|
||||
if ( typeof import.meta.env.URL !== 'undefined' ) {
|
||||
if ( hasImportMetaEnv && typeof import.meta.env.URL !== 'undefined' ) {
|
||||
console.log('Has URL')
|
||||
return import.meta.env.URL
|
||||
}
|
||||
|
||||
// Try PUBLIC_URL
|
||||
if ( typeof import.meta.env.PUBLIC_URL !== 'undefined' ) {
|
||||
if ( hasImportMetaEnv && typeof import.meta.env.PUBLIC_URL !== 'undefined' ) {
|
||||
console.log('Has PUBLIC_URL')
|
||||
return import.meta.env.PUBLIC_URL
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue