Skip to content

Commit d632888

Browse files
committed
Disabled complex proxy build
1 parent 08f7fc4 commit d632888

2 files changed

Lines changed: 61 additions & 49 deletions

File tree

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,3 +94,11 @@ This is a sub-repository to the main [OpenAD repo]. It contains the GUI which is
9494
- Update `actionSaveAs()` in `OverflowMenuMol.vue` to ensure the correct options are displayed in the overflow menu, and ensure the delete option is also included.
9595

9696
[OpenAD repo]: https://github.com/acceleratedscience/open-ad-toolkit
97+
98+
<!--
99+
100+
To delete a tag, locally and then on GH:
101+
git tag -d <tag_name>
102+
git push origin --delete <tag_name>
103+
104+
-->

vite.config.ts

Lines changed: 53 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,16 @@ export default defineConfig(({ command, mode }) => {
8282
],
8383
},
8484
}),
85-
{
86-
name: 'replace-placeholder-baseurl',
87-
closeBundle() {
88-
if (command === 'build' && mode === 'proxy') {
89-
setDynamicBaseUrl()
90-
}
91-
},
92-
},
85+
// Deprecated: hacky proxy build
86+
// - - -
87+
// {
88+
// name: 'replace-placeholder-baseurl',
89+
// closeBundle() {
90+
// if (command === 'build' && mode === 'proxy') {
91+
// setDynamicBaseUrl()
92+
// }
93+
// },
94+
// },
9395
],
9496
resolve: {
9597
alias: {
@@ -113,7 +115,7 @@ export default defineConfig(({ command, mode }) => {
113115
// Command: npm run build:proxy
114116
return {
115117
...commonConfig,
116-
base: '/__PLACEHOLDER_BASEURL__/',
118+
base: '/proxy/8024/',
117119
build: {
118120
outDir: 'gui-build-proxy',
119121
rollupOptions: {
@@ -150,43 +152,45 @@ export default defineConfig(({ command, mode }) => {
150152
}
151153
})
152154

153-
// To get the proxy build to work, we have to do some hacky post-processing
154-
// by replacing our placeholder baseUrl with a dynamic one that includes
155-
// whatever port is being used in our proxy url path.
156-
function setDynamicBaseUrl() {
157-
// A. Update the index.html file:
158-
const dir = resolve(__dirname, 'gui-build-proxy')
159-
const indexPath = resolve(dir, 'index.html')
160-
let indexHtml = readFileSync(indexPath, 'utf-8')
161-
162-
// 1) Make the main JS and CSS file paths relative so they
163-
// can be redirected using a dynamically generated base URL.
164-
indexHtml = indexHtml.replace(/\/__PLACEHOLDER_BASEURL__\//g, '')
165-
166-
// 2) Make the RDKit path relative.
167-
indexHtml = indexHtml.replace(/\/rdkit\/RDKit_minimal\.js/, 'rdkit/RDKit_minimal.js')
168-
169-
// 3) Activate the function that inserts the base URL tag
170-
// and remove the js comments.
171-
indexHtml = indexHtml.replace(/<!----/, '')
172-
indexHtml = indexHtml.replace(/\/\/ .*/, '')
173-
indexHtml = indexHtml.replace(/---->/, '')
174-
writeFileSync(indexPath, indexHtml)
175-
176-
// B. Update the main JS file:
177-
// 1) Find the name of the main JS file.
178-
const jsFilename: string | null = indexHtml.match(/<script type="module" crossorigin src="assets\/(index-\w+.js)"><\/script>/)?.[1] ?? null
179-
180-
// 2) Run a find-and-replace inside the file.
181-
if (jsFilename) {
182-
const jsPath = resolve(dir, `assets/${jsFilename}`)
183-
184-
// Replace the placeholder baseUrl.
185-
let jsFile = readFileSync(jsPath, 'utf-8')
186-
jsFile = jsFile.replace(
187-
/"\/__PLACEHOLDER_BASEURL__\/"/g,
188-
'`${window.location.pathname.match(/(.*)\\/proxy\\/\\d{4}/)?.[1] ?? ""}/proxy/${window.location.pathname.match(/\\/proxy\\/(\\d{4})/)?.[1] ?? 8024}/`',
189-
)
190-
writeFileSync(jsPath, jsFile)
191-
}
192-
}
155+
// Deprecated: hacky proxy build
156+
// - - -
157+
// // To get the proxy build to work, we have to do some hacky post-processing
158+
// // by replacing our placeholder baseUrl with a dynamic one that includes
159+
// // whatever port is being used in our proxy url path.
160+
// function setDynamicBaseUrl() {
161+
// // A. Update the index.html file:
162+
// const dir = resolve(__dirname, 'gui-build-proxy')
163+
// const indexPath = resolve(dir, 'index.html')
164+
// let indexHtml = readFileSync(indexPath, 'utf-8')
165+
166+
// // 1) Make the main JS and CSS file paths relative so they
167+
// // can be redirected using a dynamically generated base URL.
168+
// indexHtml = indexHtml.replace(/\/__PLACEHOLDER_BASEURL__\//g, '')
169+
170+
// // 2) Make the RDKit path relative.
171+
// indexHtml = indexHtml.replace(/\/rdkit\/RDKit_minimal\.js/, 'rdkit/RDKit_minimal.js')
172+
173+
// // 3) Activate the function that inserts the base URL tag
174+
// // and remove the js comments.
175+
// indexHtml = indexHtml.replace(/<!----/, '')
176+
// indexHtml = indexHtml.replace(/\/\/ .*/, '')
177+
// indexHtml = indexHtml.replace(/---->/, '')
178+
// writeFileSync(indexPath, indexHtml)
179+
180+
// // B. Update the main JS file:
181+
// // 1) Find the name of the main JS file.
182+
// const jsFilename: string | null = indexHtml.match(/<script type="module" crossorigin src="assets\/(index-\w+.js)"><\/script>/)?.[1] ?? null
183+
184+
// // 2) Run a find-and-replace inside the file.
185+
// if (jsFilename) {
186+
// const jsPath = resolve(dir, `assets/${jsFilename}`)
187+
188+
// // Replace the placeholder baseUrl.
189+
// let jsFile = readFileSync(jsPath, 'utf-8')
190+
// jsFile = jsFile.replace(
191+
// /"\/__PLACEHOLDER_BASEURL__\/"/g,
192+
// '`${window.location.pathname.match(/(.*)\\/proxy\\/\\d{4}/)?.[1] ?? ""}/proxy/${window.location.pathname.match(/\\/proxy\\/(\\d{4})/)?.[1] ?? 8024}/`',
193+
// )
194+
// writeFileSync(jsPath, jsFile)
195+
// }
196+
// }

0 commit comments

Comments
 (0)