This repository has been archived by the owner on Jun 1, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Embed generated CSS in Swift raw string literal (#288)
* Replace postcss CLI usage with custom script Write generated CSS to Swift file using raw string literal * Update README * Update .gitattributes * Update .gitignore * Update validate-assets job in CI workflow * Update generated CSS * Formatting * Consolidate watch scripts
- Loading branch information
Showing
10 changed files
with
4,024 additions
and
3,414 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
.node/package-lock.json -diff -merge | ||
.node/package-lock.json linguist-generated=true | ||
|
||
Resources/all.min.css -diff -merge | ||
Resources/all.min.css linguist-generated=true | ||
Sources/swift-doc/Generated/* -diff -merge | ||
Sources/swift-doc/Generated/* linguist-generated=true |
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 |
---|---|---|
|
@@ -5,9 +5,6 @@ | |
xcuserdata/ | ||
.swiftpm | ||
|
||
Resources/*.css | ||
!Resources/*.min.css | ||
|
||
# NodeJS | ||
## Logs | ||
logs | ||
|
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,31 @@ | ||
const fs = require("fs"); | ||
const path = require('path'); | ||
const postcss = require("postcss"); | ||
|
||
const source = "../Assets/css/all.css"; | ||
const destination = "../Sources/swift-doc/Generated/CSS.swift"; | ||
|
||
const input = fs.readFileSync(source); | ||
|
||
postcss([ | ||
require("postcss-preset-env")({ | ||
stage: 0, | ||
features: { | ||
"matches-pseudo-class": false, | ||
}, | ||
}), | ||
require("cssnano")({ | ||
preset: "default", | ||
}), | ||
]) | ||
.process(input, { from: source, to: destination }) | ||
.then((result) => { | ||
const output = [ | ||
`// This file was automatically generated and should not be edited.`, | ||
`let css: String = #"${result.css}"#`, | ||
].join("\n\n") + "\n"; | ||
|
||
fs.mkdir(path.dirname(destination), () => { | ||
fs.writeFileSync(destination, output); | ||
}); | ||
}); |
Oops, something went wrong.