diff --git a/src/libraryServer.js b/src/libraryServer.js index 5f5e4f0..dcd3d6b 100644 --- a/src/libraryServer.js +++ b/src/libraryServer.js @@ -86,7 +86,9 @@ async function start({server_port}) { function addHandlers() { app.use(express.urlencoded({extended:true, limit: '50mb'})); - app.use(express.static(SITE_PATH)); + if ( !sea.isSea() ) { + app.use(express.static(SITE_PATH)); + } if ( args.library_path() ) { app.use("/library", express.static(args.library_path())) @@ -251,6 +253,19 @@ function addHandlers() { return; } }); + + if ( sea.isSea() ) { + app.get('*', async (req, res) => { + const path = req.path; + const asset = sea.getAsset(path.slice(1)) || sea.getAsset(path.slice(1) +'.html'); + if ( asset ) { + res.type(path.split('.').pop()); + res.send(asset); + } else { + res.status(404).send('Not found'); + } + }); + } } async function stop() { diff --git a/test.sh b/test.sh index dac9ff2..8460983 100755 --- a/test.sh +++ b/test.sh @@ -1,9 +1,9 @@ #!/bin/bash # Variables -EXE_NAME=$1 -JS_SOURCE_FILE=$2 -OUTPUT_FOLDER=$3 +EXE_NAME="$1" +JS_SOURCE_FILE="$2" +OUTPUT_FOLDER="$3" # Ensure nvm is installed if ! command -v nvm &> /dev/null @@ -24,8 +24,11 @@ cat < sea-config.json "main": "${JS_SOURCE_FILE}", "output": "sea-prep.blob", "assets": { - "public": "public/**/*", - "vendor": "build/vendor/**/*" + "index.html": "public/index.html", + "top.html": "public/top.html", + "style.css": "public/style.css", + "injection.js": "public/injection.js", + "redirector.html": "public/redirector.html" } } EOF