-
Notifications
You must be signed in to change notification settings - Fork 781
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
experimental: support image processing in docker template (#4762)
Added image a route for image processing in docker template based on ipx package. There a few things to note - it does not have persistent caching and rely only on client cache control - performance is not good for remote images - the package adds 30MB to node_modules, though it will be fixed soon There is a DOMAINS env variable with comma-separated hosts to restrict remote images processing similar to netlify and vercel. Can be tested only locally for now.
- Loading branch information
Showing
10 changed files
with
953 additions
and
37 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { env } from "node:process"; | ||
import type { LoaderFunctionArgs } from "react-router"; | ||
import { | ||
createIPX, | ||
createIPXH3Handler, | ||
ipxFSStorage, | ||
ipxHttpStorage, | ||
} from "ipx"; | ||
import { createApp, toWebHandler } from "h3"; | ||
|
||
const domains = env.DOMAINS?.split(/\s*,\s*/) ?? []; | ||
|
||
const ipx = createIPX({ | ||
storage: ipxFSStorage({ dir: "./public" }), | ||
httpStorage: ipxHttpStorage({ domains }), | ||
}); | ||
|
||
const handleRequest = toWebHandler( | ||
createApp().use("/_image", createIPXH3Handler(ipx)) | ||
); | ||
|
||
export const loader = async (args: LoaderFunctionArgs) => { | ||
return handleRequest(args.request); | ||
}; |
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
24 changes: 24 additions & 0 deletions
24
packages/cli/templates/react-router-docker/app/routes/[_image].$.ts
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,24 @@ | ||
import { env } from "node:process"; | ||
import type { LoaderFunctionArgs } from "react-router"; | ||
import { | ||
createIPX, | ||
createIPXH3Handler, | ||
ipxFSStorage, | ||
ipxHttpStorage, | ||
} from "ipx"; | ||
import { createApp, toWebHandler } from "h3"; | ||
|
||
const domains = env.DOMAINS?.split(/\s*,\s*/) ?? []; | ||
|
||
const ipx = createIPX({ | ||
storage: ipxFSStorage({ dir: "./public" }), | ||
httpStorage: ipxHttpStorage({ domains }), | ||
}); | ||
|
||
const handleRequest = toWebHandler( | ||
createApp().use("/_image", createIPXH3Handler(ipx)) | ||
); | ||
|
||
export const loader = async (args: LoaderFunctionArgs) => { | ||
return handleRequest(args.request); | ||
}; |
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.