feat: add iOS simulator worktree preview
Adds the worktree service, setup cache seeding, and Metro preview mount for /.sim. Also includes the related startup and mobile sidebar fixes needed by the updated worktree app flow.
This commit is contained in:
@@ -78,4 +78,31 @@ config.resolver.resolveRequest = (context, moduleName, platform) => {
|
||||
return resolveWithCustomWebOverlay(context, moduleName, platform);
|
||||
};
|
||||
|
||||
if (process.env.PASEO_SERVE_SIM_PREVIEW === "1") {
|
||||
const { simMiddleware } = require("serve-sim/middleware");
|
||||
const originalEnhanceMiddleware = config.server?.enhanceMiddleware;
|
||||
config.server = config.server ?? {};
|
||||
config.server.enhanceMiddleware = (metroMiddleware, server) => {
|
||||
const middleware = originalEnhanceMiddleware
|
||||
? originalEnhanceMiddleware(metroMiddleware, server)
|
||||
: metroMiddleware;
|
||||
const serveSimulator = simMiddleware({
|
||||
basePath: "/.sim",
|
||||
device: process.env.PASEO_SERVE_SIM_DEVICE_UDID,
|
||||
});
|
||||
return (req, res, next) => {
|
||||
serveSimulator(req, res, (error) => {
|
||||
if (error) {
|
||||
if (next) {
|
||||
next(error);
|
||||
return;
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
middleware(req, res, next);
|
||||
});
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = config;
|
||||
|
||||
Reference in New Issue
Block a user