Skip to content

Commit e3f7a84

Browse files
committed
create script to map fonts
1 parent dee6684 commit e3f7a84

20 files changed

+399
-98
lines changed

package-lock.json

Lines changed: 329 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"build": "rm -rf build && npm run build:ext && npm run build:web",
2121
"build:ext": "tsc -p ./",
2222
"build:web": "cd web-app && npm run build",
23-
"postbuild:web": "cp -R ./web-app/build/ ./build/",
23+
"postbuild:web": "cp -R ./web-app/build/ ./build/ && node scripts/fixFontPaths.js",
2424
"postinstall": "node ./node_modules/vscode/bin/install",
2525
"lint": "eslint src/**/*ts",
2626
"machine": "node ./out/state/index.js",
@@ -50,8 +50,10 @@
5050
"eslint": "^6.8.0",
5151
"eslint-config-prettier": "^6.10.0",
5252
"eslint-plugin-prettier": "^3.1.2",
53+
"glob": "^7.1.6",
5354
"graphql": "^14.6.0",
5455
"prettier": "^1.19.1",
56+
"resolve-url-loader": "^3.1.1",
5557
"ts-jest": "^25.1.0",
5658
"typescript": "^3.7.5",
5759
"vscode": "^1.1.36",

resources/public/favicon.ico

-3.78 KB
Binary file not shown.

resources/public/index.html

Lines changed: 0 additions & 40 deletions
This file was deleted.

resources/public/manifest.json

Lines changed: 0 additions & 15 deletions
This file was deleted.

scripts/fixFontPaths.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* css url font paths do not match up from the web-app as it is moved inside of build
3+
* in order to load fonts and icons, these paths must be reconciled.
4+
*/
5+
const fs = require('fs') // eslint-disable-line
6+
7+
// find the generated main css file
8+
const getMainCSSFile = () => {
9+
const regex = /^main.[a-z0-9]+.chunk.css$/
10+
const mainCss = fs.readdirSync('build/static/css').filter(filename => filename.match(regex))
11+
if (!mainCss.length) {
12+
throw new Error('No main.css file found in build/static/css')
13+
}
14+
return mainCss[0]
15+
}
16+
17+
// remap the font paths from the borken /fonts/ => ../../fonts/
18+
const remapFontPaths = () => {
19+
const mainCSSFile = getMainCSSFile()
20+
const file = fs.readFileSync(`build/static/css/${mainCSSFile}`, 'utf8')
21+
const fontUrlRegex = /url\(\/fonts\//g
22+
const remappedFile = file.replace(fontUrlRegex, 'url(../../fonts/')
23+
fs.writeFileSync(`build/static/css/${mainCSSFile}`, remappedFile)
24+
}
25+
26+
remapFontPaths()

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,5 @@
2525
"allowJs": true,
2626
"removeComments": true
2727
},
28-
"exclude": ["node_modules", ".vscode-test", "build", "resources", "web-app", "*.js", "*.test.ts"]
28+
"exclude": ["node_modules", ".vscode-test", "build", "resources", "web-app", "*.js", "*.test.ts", "scripts"]
2929
}

web-app/.storybook/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { configure } from '@storybook/react'
2-
import '../src/styles/index.scss'
2+
import '../src/styles/index.css'
33

44
// setup acquireVsCodeApi mock
55
// @ts-ignore

web-app/src/containers/LoadingPage.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import * as React from 'react'
22
import * as T from 'typings'
33
import { css, jsx } from '@emotion/core'
44
import Loading from '../components/Loading'
5-
import { Icon } from '@alifd/next'
65
import Message from '../components/Message'
76

87
interface Props {
@@ -32,7 +31,6 @@ const LoadingPage = ({ text, context }: Props) => {
3231
}
3332
return (
3433
<div css={styles.page}>
35-
<Icon type="smile" />
3634
<Loading text={text} />
3735
</div>
3836
)

web-app/src/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import App from './App'
55
// init error logging
66
import './services/sentry/init'
77
// init initial styles
8-
import './styles/index.scss'
8+
import './styles/index.css'
99
// init listeners
1010
import './services/listeners'
1111

0 commit comments

Comments
 (0)