fix: port applicable fixes from mostlyserious/craftcms#4 - #1
Merged
Conversation
Hashing asset.source.toString() is lossy for binary images, so distinct images could collide on the same cache key. The plugin also read TINYPNG_KEY from process.env, which SvelteKit never populates from .env during builds; the key is now loaded via loadEnv and passed as a plugin option.
Wrapping excluded markup in <template> still ships it in the page source; return an empty string instead.
Greptile SummaryThis PR ports fixes for image sizing, Tinify cache correctness and environment loading, environment-specific Twig output, menu-query performance, and safer installer reruns.
Confidence Score: 5/5The PR appears safe to merge with no concrete changed-code defects identified. The modified paths preserve their existing contracts while correcting cache hashing, environment-key propagation, image metadata, markup suppression, query loading, and installer file preservation. Important Files Changed
Reviews (1): Last reviewed commit: "chore: preserve existing .env files in i..." | Re-trigger Greptile |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Ports the fixes from mostlyserious/craftcms#4 that apply to this repo's architecture. The module-lifecycle, lightbox, and Modal changes from that PR have no counterparts here and were skipped.
frontend/src/lib/util/image.ts- the 2x srcset URL no longer emits?width=0&height=0when no transform dimensions are given, andwidth/heightattributes fall back to the asset's intrinsic size instead of0.vite-plugin-tinify(both copies) - the cache checksum now hashes the raw image bytes instead ofasset.source.toString(), which was lossy for binary data and could collide across distinct images, serving the wrong cached file.frontend/vite.config.ts- the Tinify API key is now loaded vialoadEnvand passed as a plugin option. The plugin previously readprocess.env.TINYPNG_KEY, which SvelteKit never populates from.envduring builds, so production builds with uncached images would always throw.TINYPNG_KEYadded tofrontend/.env.example.GeneralExtension::onlyEnv- returns an empty string for non-matching environments instead of wrapping the markup in<template>, which still shipped it in the page source.Serializer::menuItems- nested menu link queries are eager loaded, removing the N+1 when serializing dropdown navigation items.utility/install.sh- existingbackend/.envandfrontend/.envfiles are no longer clobbered on re-run (previously wiped security keys on an existing install)..gitignoregains/.pnpm-store;.zed/settings.jsonswitchestsgototypescript-lsto match the source repo.Testing
pnpm run lint- only pre-existing warnings.pnpm run check(svelte-check) - 0 errors.pnpm run test-image.test.tsand all other suites pass;formie-schema.test.tsfails identically onmain(pre-existing).backend/vendor/bin/pint --testpasses on both modified PHP files.main(182 pre-existing findings, none on changed lines).🤖 Generated with Claude Code
Note
Port bug fixes and small feature improvements from upstream fork
image.attributesin frontend/src/lib/util/image.ts to avoid zero-value width/height in 2x srcset URLs and fall back to intrinsic asset dimensions when not specified.Serializer.menuItemsto calleagerly()->all()instead ofall()when fetching menu item query results.GeneralExtensionconditional markup method to return an empty string instead of a<template>wrapper when the environment is not in the allowed list.vite-plugin-tinifyto accept an options object with an explicitkeyinstead of readingprocess.env.TINYPNG_KEY, and computes SHA1 checksums from the raw asset buffer rather than its string representation..env.examplefiles if.envalready exists, preventing overwriting existing environment config.Macroscope summarized ff7059a.