Skip to content

Commit

Permalink
fix: handle generically
Browse files Browse the repository at this point in the history
  • Loading branch information
bluwy committed Nov 29, 2022
1 parent 37e6c96 commit 93667de
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions packages/vite/src/node/plugins/css.ts
Expand Up @@ -1499,9 +1499,20 @@ function loadPreprocessor(
}
}

// in unix, scss might append http://localhost in environments that shim `location`
// in unix, scss might append `location.href` in environments that shim `location`
// see https://github.com/sass/dart-sass/issues/710
const cleanScssBugUrl = (url: string) => url.replace(/^http:\/\/localhost/, '')
function cleanScssBugUrl(url: string) {
if (
// check bug via `window` and `location` global
typeof window !== 'undefined' &&
typeof location !== 'undefined'
) {
const prefix = location.href.replace(/\/$/, '')
return url.replace(prefix, '')
} else {
return url
}
}

function fixScssBugImportValue(
data: Sass.ImporterReturnType
Expand Down

0 comments on commit 93667de

Please sign in to comment.