You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
echo"Warning: $js_file not found. Caching logic not injected."
147
-
fi
148
-
}
149
168
169
+
# Replace openmina_node_web_bg.wasm with openmina_node_web_bg.<hash>.wasm in JS file
170
+
sed -i "s/openmina_node_web_bg\.wasm/openmina_node_web_bg.${wasm_file_hash}.wasm/g""$js_file"|| { echo"Failed to update wasm filename in $js_file";return 1; }
171
+
172
+
# Add cache headers to fetch calls in JS file
173
+
sed -i 's/module_or_path = fetch(module_or_path);/module_or_path = fetch(module_or_path, { cache: "force-cache", headers: { "Cache-Control": "max-age=31536000, immutable" } });/'"$js_file"|| { echo"Failed to inject cache headers into $js_file";return 1; }
174
+
175
+
# Rename wasm file with hash
176
+
mv "$wasm_target_file""$wasm_new_file"|| { echo"Failed to rename $wasm_target_file to $wasm_new_file";return 1; }
177
+
178
+
# Rename JS file with hash
179
+
mv "$js_target_file""$js_new_file"|| { echo"Failed to rename $js_target_file to $js_new_file";return 1; }
180
+
181
+
# Replace JS filename in index.html
182
+
sed -i "s/openmina_node_web\.js/openmina_node_web.${js_file_hash}.js/g""$index_html"|| { echo"Failed to update JS filename in $index_html";return 1; }
183
+
184
+
echo"Successfully injected caching logic into $js_file"
0 commit comments