-
Notifications
You must be signed in to change notification settings - Fork 0
/
createfontscss.js
52 lines (43 loc) · 1.53 KB
/
createfontscss.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import fs from "fs"
const FontsCssFilePath = "./src/styles/fonts.css"
const StoryBookFontsCssFilePath = "./.storybook/fonts.css"
import dotenv from "dotenv"
dotenv.config()
let basepath = process.env.PUBLIC_IMPRESSO_DATALAB_BASE || ""
// remove final slash if any
if (basepath.endsWith("/")) {
basepath = basepath.slice(0, -1)
}
console.log("PUBLIC_IMPRESSO_DATALAB_BASE")
console.log("fonts.css path:", FontsCssFilePath)
console.log("basepath:", basepath)
const fonts = (basepath) => `
@font-face {
font-family: "Satoshi-Variable";
src: url("${basepath}/fonts/Satoshi-Variable.woff2") format("woff2"),
url("${basepath}/fonts/Satoshi-Variable.woff") format("woff"),
url("${basepath}/fonts/Satoshi-Variable.ttf") format("truetype");
font-weight: 300 900;
font-display: swap;
font-style: normal;
}
@font-face {
font-family: "Satoshi-VariableItalic";
src: url("${basepath}/fonts/Satoshi-VariableItalic.woff2") format("woff2"),
url("${basepath}/fonts/Satoshi-VariableItalic.woff") format("woff"),
url("${basepath}/fonts/Satoshi-VariableItalic.ttf") format("truetype");
font-weight: 300 900;
font-display: swap;
font-style: italic;
}
body{
background-image: url("${basepath}/background.png");
background-attachment: fixed;
background-size: cover;
}
`
console.log("fonts.css expected contents:", fonts(basepath))
fs.writeFileSync(FontsCssFilePath, fonts(basepath))
console.log("fonts.css updated.")
fs.writeFileSync(StoryBookFontsCssFilePath, fonts("../public"))
console.log(`${StoryBookFontsCssFilePath} updated.`)