-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a5830d1
commit eddfcd1
Showing
10 changed files
with
79 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
"use strict" | ||
|
||
const formatImportPrelude = require("./format-import-prelude") | ||
|
||
// Base64 encode an import with conditions | ||
// The order of conditions is important and is interleaved with cascade layer declarations | ||
// Each group of conditions and cascade layers needs to be interpreted in order | ||
// To achieve this we create a list of base64 encoded imports, where each import contains a stylesheet with another import. | ||
// Each import can define a single group of conditions and a single cascade layer. | ||
module.exports = function base64EncodedConditionalImport(prelude, conditions) { | ||
conditions.reverse() | ||
const first = conditions.pop() | ||
let params = `${prelude} ${formatImportPrelude( | ||
first.layer, | ||
first.media, | ||
first.supports | ||
)}` | ||
|
||
for (const condition of conditions) { | ||
params = `'data:text/css;base64,${Buffer.from(`@import ${params}`).toString( | ||
"base64" | ||
)}' ${formatImportPrelude( | ||
condition.layer, | ||
condition.media, | ||
condition.supports | ||
)}` | ||
} | ||
|
||
return params | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters