-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update frontend to new bundling code from OLS
- Loading branch information
Showing
16 changed files
with
6,002 additions
and
8,801 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { exec } from "child_process"; | ||
import { build } from "esbuild"; | ||
import fs from "fs"; | ||
|
||
let define = {}; | ||
for (const k in process.env) { | ||
define[`process.env.${k}`] = JSON.stringify(process.env[k]); | ||
} | ||
|
||
/// | ||
/// Build index.html (simple find and replace) | ||
/// | ||
console.log("### Building index.html"); | ||
fs.writeFileSync( | ||
"dist/index.html", | ||
fs | ||
.readFileSync("index.html.in") | ||
.toString() | ||
.split("%PUBLIC_URL%/") | ||
.join(process.env.PUBLIC_URL || "/") | ||
.split("%PUBLIC_URL%") | ||
.join(process.env.PUBLIC_URL || "/") | ||
); | ||
|
||
/// | ||
/// Build bundle.js (esbuild) | ||
/// | ||
console.log("### Building bundle.js"); | ||
build({ | ||
entryPoints: ["src/index.tsx"], | ||
bundle: true, | ||
platform: "browser", | ||
outfile: "dist/bundle.js", | ||
define, | ||
plugins: [], | ||
logLevel: "info", | ||
sourcemap: "linked", | ||
|
||
...(process.env.OXO_MINIFY === "true" | ||
? { | ||
minify: true, | ||
} | ||
: {}), | ||
}); | ||
|
||
/// | ||
/// Build styles.css (tailwind) | ||
/// | ||
console.log("### Building styles.css"); | ||
exec("tailwind -i ./src/index.css -o ./dist/styles.css"); | ||
|
||
/// | ||
/// Copy files | ||
/// | ||
// console.log("### Copying misc files"); | ||
// exec("cp ./src/banner.txt ./dist"); // home page banner text | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
|
||
import express from 'express' | ||
import fetch from 'node-fetch' | ||
import urlJoin from 'url-join' | ||
import nocache from 'nocache' | ||
|
||
|
||
let server = express() | ||
|
||
server.use(nocache()) | ||
|
||
if(process.env.OXO_DEV_BACKEND_PROXY_URL === undefined) { | ||
throw new Error('please set OXO_DEV_BACKEND_PROXY_URL before running dev server') | ||
} | ||
server.use(/^\/api.*/, async (req, res) => { | ||
let backendUrl = urlJoin(process.env.OXO_DEV_BACKEND_PROXY_URL, req.originalUrl) | ||
console.log('forwarding api request to: ' + backendUrl) | ||
try { | ||
let apiResponse = await fetch(backendUrl, { | ||
redirect: 'follow', | ||
method: req.method, | ||
body: req.body | ||
}) | ||
res.header('content-type', apiResponse.headers.get('content-type')) | ||
res.status(apiResponse.status) | ||
apiResponse.body.pipe(res) | ||
} catch(e) { | ||
console.log(e) | ||
} | ||
}) | ||
|
||
|
||
server.use(express.static('dist')) | ||
|
||
server.get(/^(?!\/api).*$/, (req, res) => { | ||
res.sendFile(process.cwd() + '/dist/index.html') | ||
}) | ||
|
||
|
||
|
||
|
||
server.listen(3000) | ||
|
||
|
||
|
||
|
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.