Skip to content

Commit b2c2eea

Browse files
committed
fix: update build process and paths for PR preview deployment
1 parent 3e46af9 commit b2c2eea

3 files changed

Lines changed: 93 additions & 61 deletions

File tree

.github/workflows/pr-preview.yml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,7 @@ jobs:
3636
- name: Build compas-open-scd
3737
if: github.event.action != 'closed'
3838
run: |
39-
npm run build
40-
41-
- name: Rewrite absolute paths for PR preview
42-
if: github.event.action != 'closed'
43-
run: |
44-
sed -i 's|src="/|src="|g; s|href="/|href="|g' packages/compas-open-scd/build/index.html
39+
PUBLIC_URL=compas-open-scd/pr-preview/pr-$PR_NUMBER npm run-script build
4540
4641
- name: Deploy preview
4742
uses: rossjrw/pr-preview-action@v1
Lines changed: 90 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,98 @@
1-
<!doctype html>
1+
<!DOCTYPE html>
22
<html lang="en">
3+
<head>
4+
<meta charset="utf-8" />
35

4-
<head>
5-
<meta charset="utf-8">
6+
<meta
7+
http-equiv="Cache-control"
8+
content="no-cache, no-store, must-revalidate"
9+
/>
10+
<meta http-equiv="Pragma" content="no-cache" />
11+
<meta http-equiv="Expires" content="0" />
612

7-
<meta http-equiv="Cache-control" content="no-cache, no-store, must-revalidate">
8-
<meta http-equiv="Pragma" content="no-cache">
9-
<meta http-equiv="Expires" content="0">
13+
<meta
14+
name="viewport"
15+
content="width=device-width, initial-scale=1.0, viewport-fit=cover"
16+
/>
17+
<meta
18+
name="Description"
19+
content="Open Substation Communication Designer is a bottom-up system configuration tool for projects described using IEC 61850-6 Edition 2 or greater."
20+
/>
21+
<base href="/" />
1022

11-
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover" />
12-
<meta name="Description"
13-
content="Open Substation Communication Designer is a bottom-up system configuration tool for projects described using IEC 61850-6 Edition 2 or greater.">
14-
<base href="/">
23+
<!-- Original URL from Google: https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@300&family=Roboto:wght@300;400;500&display=swap -->
24+
<link
25+
href="%PUBLIC_URL%/public/google/fonts/roboto-v27.css"
26+
rel="stylesheet"
27+
/>
28+
<link
29+
href="%PUBLIC_URL%/public/google/fonts/roboto-mono-v13.css"
30+
rel="stylesheet"
31+
/>
32+
<!-- Original URL from Google: https://fonts.googleapis.com/css?family=Material+Icons+Outlined&display=block -->
33+
<link
34+
href="%PUBLIC_URL%/public/google/icons/material-icons-outlined.css"
35+
rel="stylesheet"
36+
/>
37+
<link
38+
href="%PUBLIC_URL%/public/google/icons/material-symbols-outlined.css"
39+
rel="stylesheet"
40+
/>
41+
<link href="%PUBLIC_URL%/public/css/normalize.css" rel="stylesheet" />
42+
<link
43+
rel="manifest"
44+
href="%PUBLIC_URL%/manifest.json"
45+
crossorigin="use-credentials"
46+
/>
47+
<link
48+
rel="icon"
49+
type="image/png"
50+
sizes="16x16"
51+
href="%PUBLIC_URL%/public/favicon-16x16.png"
52+
/>
53+
<link
54+
rel="icon"
55+
type="image/png"
56+
sizes="32x32"
57+
href="%PUBLIC_URL%/public/favicon-32x32.png"
58+
/>
59+
<link
60+
rel="icon"
61+
type="image/png"
62+
sizes="192x192"
63+
href="%PUBLIC_URL%/public/icon-192x192.png"
64+
/>
1565

16-
<!-- Original URL from Google: https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@300&family=Roboto:wght@300;400;500&display=swap -->
17-
<link href="/public/google/fonts/roboto-v27.css" rel="stylesheet">
18-
<link href="/public/google/fonts/roboto-mono-v13.css" rel="stylesheet">
19-
<!-- Original URL from Google: https://fonts.googleapis.com/css?family=Material+Icons+Outlined&display=block -->
20-
<link href="/public/google/icons/material-icons-outlined.css" rel="stylesheet">
21-
<link href="/public/google/icons/material-symbols-outlined.css" rel="stylesheet">
22-
<link href="/public/css/normalize.css" rel="stylesheet">
23-
<link rel="manifest" href="manifest.json" crossorigin="use-credentials">
24-
<link rel="icon" type="image/png" sizes="16x16" href="public/favicon-16x16.png">
25-
<link rel="icon" type="image/png" sizes="32x32" href="public/favicon-32x32.png">
26-
<link rel="icon" type="image/png" sizes="192x192" href="public/icon-192x192.png">
66+
<title>CoMPAS - OpenSCD</title>
67+
</head>
2768

28-
<title>CoMPAS - OpenSCD</title>
29-
</head>
69+
<body>
70+
<open-scd></open-scd>
3071

31-
<body>
32-
<open-scd></open-scd>
72+
<script src="./src/polyfill/scoped-custom-elements-polyfill.js"></script>
3373

34-
<script src="./src/polyfill/scoped-custom-elements-polyfill.js"></script>
35-
36-
<script>
37-
const _customElementsDefine = window.customElements.define;
38-
window.customElements.define = (name, cl, conf) => {
39-
if (!customElements.get(name)) {
40-
_customElementsDefine.call(window.customElements, name, cl, conf);
41-
}
42-
};
43-
</script>
44-
<script type="module" src="./src/open-scd.js"></script>
45-
<script src="./public/init-js/init.js"></script>
46-
<script>
47-
if ('serviceWorker' in navigator)
48-
navigator.serviceWorker.register('/sw.js');
49-
</script>
50-
<script>
51-
const openScd = document.querySelector("open-scd");
52-
addEventListener("beforeunload", e => {
53-
if (openScd && openScd.doc) {
54-
e.preventDefault();
55-
return e.returnValue = "Are you sure you want to exit?";
56-
}
57-
});
58-
</script>
59-
</body>
60-
61-
</html>
74+
<script>
75+
const _customElementsDefine = window.customElements.define;
76+
window.customElements.define = (name, cl, conf) => {
77+
if (!customElements.get(name)) {
78+
_customElementsDefine.call(window.customElements, name, cl, conf);
79+
}
80+
};
81+
</script>
82+
<script type="module" src="./src/open-scd.js"></script>
83+
<script src="%PUBLIC_URL%/public/init-js/init.js"></script>
84+
<script>
85+
if ('serviceWorker' in navigator)
86+
navigator.serviceWorker.register('/sw.js');
87+
</script>
88+
<script>
89+
const openScd = document.querySelector('open-scd');
90+
addEventListener('beforeunload', e => {
91+
if (openScd && openScd.doc) {
92+
e.preventDefault();
93+
return (e.returnValue = 'Are you sure you want to exit?');
94+
}
95+
});
96+
</script>
97+
</body>
98+
</html>

packages/compas-open-scd/snowpack.config.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,6 @@ export default ({
4545
},
4646
buildOptions: {
4747
htmlFragments: true,
48-
}
48+
baseUrl: process.env.PUBLIC_URL || '/',
49+
},
4950
});
50-

0 commit comments

Comments
 (0)