Skip to content

Commit b4eb2f2

Browse files
committed
perf: fingerprint production assets
1 parent 6a48455 commit b4eb2f2

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

app/utils/assets.server.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export let assetServer = createAssetServer({
1818
"app/data/**",
1919
"app/middleware/**",
2020
],
21+
fingerprint: isDevelopment ? undefined : { buildId: getBuildId() },
2122
sourceMaps: isDevelopment ? "external" : undefined,
2223
minify: !isDevelopment,
2324
scripts: {
@@ -29,3 +30,13 @@ export let assetServer = createAssetServer({
2930
},
3031
watch: false,
3132
});
33+
34+
function getBuildId() {
35+
let buildId = process.env.ASSET_BUILD_ID || process.env.FLY_IMAGE_REF;
36+
if (!buildId) {
37+
throw new Error(
38+
"ASSET_BUILD_ID or FLY_IMAGE_REF is required for production asset fingerprinting",
39+
);
40+
}
41+
return buildId;
42+
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"push:stage": "git tag -f stage && git push origin stage -f",
1919
"browser": "playwright-cli",
2020
"start": "cross-env NODE_ENV=production node --import remix/node-tsx server.ts",
21-
"preview": "cross-env NODE_ENV=production node --env-file=.env --import remix/node-tsx server.ts",
21+
"preview": "cross-env NODE_ENV=production ASSET_BUILD_ID=local-preview node --env-file=.env --import remix/node-tsx server.ts",
2222
"lint": "oxlint .",
2323
"lint:fix": "oxlint . --fix",
2424
"pretest": "pnpm run build:css",

0 commit comments

Comments
 (0)