diff --git a/Package.resolved b/Package.resolved index 38c2bdd..4a8df8f 100644 --- a/Package.resolved +++ b/Package.resolved @@ -59,8 +59,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-nio.git", "state" : { - "revision" : "f7c46552983b06b0958a1a4c8bc5199406ae4c8a", - "version" : "2.51.0" + "revision" : "6213ba7a06febe8fef60563a4a7d26a4085783cf", + "version" : "2.54.0" } } ], diff --git a/Plugins/VercelPackager/Server/server.js b/Plugins/VercelPackager/Server/server.js index e0f1134..0f3f40e 100644 --- a/Plugins/VercelPackager/Server/server.js +++ b/Plugins/VercelPackager/Server/server.js @@ -1,4 +1,6 @@ const http = require('http') +const path = require('path') +const fs = require('fs') const port = Number(process.argv[2] || 7676) async function invoke(payload) { @@ -26,7 +28,20 @@ async function readBody(stream) { }) } +function serveStaticFile(req, res) { + const localPath = path.join(process.env.SWIFT_PROJECT_DIRECTORY, 'public', req.url) + const data = fs.readFileSync(localPath) + res.writeHead(200, {}) + res.end(data) +} + const server = http.createServer(async (req, res) => { + try { + serveStaticFile(req, res) + return + } catch (err) { + // ignore + } try { const method = req.method const path = req.url diff --git a/Plugins/VercelPackager/VercelOutput.swift b/Plugins/VercelPackager/VercelOutput.swift index d3bbf20..4ca3df4 100644 --- a/Plugins/VercelPackager/VercelOutput.swift +++ b/Plugins/VercelPackager/VercelOutput.swift @@ -99,7 +99,8 @@ public struct VercelOutput { arguments: [ projectDirectory.appending([".build", "checkouts", "Vercel", "Plugins", "VercelPackager", "Server", "server.js"]).string, port - ] + ], + environment: ["SWIFT_PROJECT_DIRECTORY": projectDirectory.string] ) }