-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
style: minify GraphQL Playground CSS
- Loading branch information
Showing
9 changed files
with
75 additions
and
989 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 |
---|---|---|
|
@@ -4,3 +4,4 @@ rusty-tags.vi | |
video.tape | ||
*.profraw | ||
sqlite.db* | ||
/assets |
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 @@ | ||
deno.lock:generic-api-key:10 |
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,21 @@ | ||
{ | ||
"fmt": { | ||
"include": ["./**/*.ts"], | ||
"exclude": ["public/", "target/"] | ||
}, | ||
"lint": { | ||
"exclude": ["public/", "target/"], | ||
"rules": { | ||
"tags": ["recommended"] | ||
} | ||
}, | ||
"tasks": { | ||
"fmt": "yamlfmt . && dprint fmt && deno fmt && cargo fmt", | ||
"minify:css": "deno run --allow-env --allow-read --allow-net --allow-run --allow-write scripts/minify-css.ts" | ||
}, | ||
"imports": { | ||
"@/": "./", | ||
"browserslist": "https://esm.sh/browserslist@4.24.2", | ||
"lightningcss": "https://esm.sh/lightningcss-wasm@1.28.1" | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 @@ | ||
[] |
Large diffs are not rendered by default.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,37 @@ | ||
import browserslist from "browserslist"; | ||
import init, { browserslistToTargets, transform } from "lightningcss"; | ||
|
||
await init(); | ||
|
||
const targets = browserslistToTargets( | ||
browserslist( | ||
"> 0.5%, last 2 versions, Firefox >= 102, Firefox ESR, not dead", | ||
), | ||
); | ||
|
||
async function minifyStylesheet(path: string) { | ||
try { | ||
const inputPath = `./assets/${path}`; | ||
const outputPath = `./public/${path}`; | ||
const css = await Deno.readTextFile(inputPath); | ||
const { code: outputCss } = transform({ | ||
filename: inputPath, | ||
code: new TextEncoder().encode(css), | ||
minify: true, | ||
targets, | ||
}); | ||
|
||
const decoder = new TextDecoder(); | ||
await Deno.writeTextFile(outputPath, `${decoder.decode(outputCss)}\n`); | ||
} catch (error: unknown) { | ||
console.error( | ||
`Error building styles for path ${path}: ${error as string}`, | ||
); | ||
} | ||
} | ||
|
||
const cssFiles = ["fonts/fonts.css", "static/css/index.css"]; | ||
|
||
for await (const file of cssFiles) { | ||
minifyStylesheet(file); | ||
} |