Skip to content

Windows run #259

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Apr 13, 2020
Next Next commit
WIP: fix extension to run on windows computers
Signed-off-by: argemiront <argemiront@gmail.com>
  • Loading branch information
argemiront committed Apr 13, 2020
commit 6bafe24304bc0ee259520558e1285a6ac78684d8
4 changes: 3 additions & 1 deletion scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ tsc -p ./
cd web-app
npm run build
cd ..
cp -R ./web-app/build/ ./build/
# For Windows build: switch the next 2 lines
# cp -R ./web-app/build/ ./
cp -R ./web-app/build/ ./build
Comment on lines +18 to +19
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we wrap these in a os platform conditional in bash?

node scripts/fixFontPaths.js

echo "Build complete!"
17 changes: 6 additions & 11 deletions src/webview/render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,18 @@ async function render(panel: vscode.WebviewPanel, rootPath: string) {

// set base href
const base: HTMLBaseElement = document.createElement('base')
base.href = `vscode-resource:${rootPath}/`
base.href = `${vscode.Uri.file(path.join(rootPath, 'build')).with({ scheme: 'vscode-resource' })}`

document.head.appendChild(base)

// used for CSP
const nonces: string[] = []

// generate vscode-resource build path uri
const createUri = (filePath: string): any => {
return (
panel.webview
// @ts-ignore
.asWebviewUri(vscode.Uri.file(filePath))
.toString()
.replace(/^\/+/g, '') // remove leading '/'
.replace('/vscode-resource%3A', rootPath)
) // replace mangled resource path with root
const createUri = (_filePath: string): any => {
const filePath = (_filePath.startsWith('vscode') ? _filePath.substr(16) : _filePath).replace('///', '\\')

return panel.webview.asWebviewUri(vscode.Uri.file(path.join(rootPath, filePath)))
}

// fix paths for scripts
Expand All @@ -55,7 +50,7 @@ async function render(panel: vscode.WebviewPanel, rootPath: string) {
runTimeScript.nonce = getNonce()
nonces.push(runTimeScript.nonce)
const manifest = await import(path.join(rootPath, 'asset-manifest.json'))
runTimeScript.src = createUri(path.join(rootPath, manifest.files['runtime-main.js']))
runTimeScript.src = createUri(manifest.files['runtime-main.js'])
document.body.appendChild(runTimeScript)

// fix paths for links
Expand Down
38 changes: 20 additions & 18 deletions web-app/public/index.html
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
<meta name="theme-color" content="#000000" />
<!--

<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
<meta name="theme-color" content="#000000" />
<!--
manifest.json provides metadata used when your web app is added to the
homescreen on Android. See https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico" />
<!--
<link rel="manifest" href="manifest.json" />
<link rel="shortcut icon" href="favicon.ico" />
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Expand All @@ -19,15 +20,15 @@
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>CodeRoad</title>
</head>
<title>CodeRoad</title>
</head>

<body>
<noscript>
You need to enable JavaScript to run this app.
</noscript>
<div id="root"></div>
<!--
<body>
<noscript>
You need to enable JavaScript to run this app.
</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.

Expand All @@ -37,5 +38,6 @@
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>
</body>

</html>