Skip to content

Commit

Permalink
fix: less stylesheets as global resources
Browse files Browse the repository at this point in the history
  • Loading branch information
pmrotule committed Sep 6, 2021
1 parent 411d1e8 commit af32ba1
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions lib/process-style.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,20 @@ function getGlobalResources(resources, lang, filePath) {
if (resources && resources[lang]) {
globalResources = resources[lang]
.map(resource => {
const relativePath = path.relative(
path.dirname(filePath),
path.resolve(process.cwd(), resource)
)
return `${getImportLine(lang, relativePath)}\n`
const absolutePath = path.resolve(process.cwd(), resource)
return `${getImportLine(lang, absolutePath)}\n`
})
.join('')
}
return globalResources
}

function getImportLine(lang, filePath) {
const placeholder = '__PATH__'
const formats = {
default: `@import "${placeholder}";`,
sass: `@import "${placeholder}"`
const importLines = {
default: `@import "${filePath}";`,
sass: `@import "${filePath}"`
}
return (formats[lang] || formats.default).replace(placeholder, filePath)
return importLines[lang] || importLines.default
}

function extractClassMap(cssCode) {
Expand Down

0 comments on commit af32ba1

Please sign in to comment.