Skip to content

Commit c678e72

Browse files
ccharlyclaude
andcommitted
fix(snap-simple-keyring): fix site build in monorepo context
- Remove icon from gatsby-plugin-manifest to avoid sharp native binary, which cannot run its install script in the monorepo's isolated node_modules (lavamoat allow-scripts only scans root node_modules) - Add raw-loader to site devDependencies; gatsby-plugin-webfonts@2.3.2 uses it via inline loader syntax but does not declare it as a dependency - Add @metamask/keyring-snap-client to build:snaps:deps; the site depends on it and webpack fails to resolve it if its dist/ doesn't exist Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 73bb27c commit c678e72

7 files changed

Lines changed: 37 additions & 2 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"build": "ts-bridge --project tsconfig.build.json",
1818
"build:clean": "yarn build --clean",
1919
"build:snaps": "yarn build:snaps:deps && yarn workspaces foreach --all --include '@metamask/snap-simple-keyring' --parallel --verbose run build",
20-
"build:snaps:deps": "yarn workspaces foreach --all --include '@metamask/keyring-utils' --include '@metamask/keyring-api' --include '@metamask/keyring-snap-sdk' --topological --verbose run build",
20+
"build:snaps:deps": "yarn workspaces foreach --all --include '@metamask/keyring-utils' --include '@metamask/keyring-api' --include '@metamask/keyring-snap-sdk' --include '@metamask/keyring-snap-client' --topological --verbose run build",
2121
"build:docs": "yarn foreach build:docs",
2222
"build:only-clean": "rimraf -g 'packages/*/dist'",
2323
"build:types": "tsc --build tsconfig.build.json --verbose",

packages/snaps/simple-keyring/packages/site/gatsby-config.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,24 @@ const config: GatsbyConfig = {
1414
resolve: 'gatsby-plugin-manifest',
1515
options: {
1616
name: 'Template Snap',
17-
icon: 'src/assets/logo.svg',
1817
theme_color: '#6F4CFF',
1918
background_color: '#FFFFFF',
2019
display: 'standalone',
20+
// Pre-built icons avoid sharp (native binary) which can't run its
21+
// install script in the monorepo's isolated node_modules. Regenerate
22+
// from src/assets/logo.svg if the icon changes.
23+
icons: [
24+
{
25+
src: 'icons/icon-192.png',
26+
sizes: '192x192',
27+
type: 'image/png',
28+
},
29+
{
30+
src: 'icons/icon-512.png',
31+
sizes: '512x512',
32+
type: 'image/png',
33+
},
34+
],
2135
},
2236
},
2337
{

packages/snaps/simple-keyring/packages/site/gatsby-ssr.tsx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,25 @@ import React, { StrictMode } from 'react';
44
import { App } from './src/App';
55
import { Root } from './src/Root';
66

7+
// Inject the favicon manually instead of relying on gatsby-plugin-manifest's
8+
// `icon` option, which uses sharp to resize images. sharp requires a native
9+
// binary that cannot be installed in the monorepo (lavamoat's allow-scripts
10+
// plugin only scans root node_modules, so packages isolated by
11+
// hoistingLimits: "workspaces" are invisible to it). The pre-built PNGs in
12+
// static/icons/ are committed directly and referenced here.
13+
export const onRenderBody: GatsbySSR['onRenderBody'] = ({
14+
setHeadComponents,
15+
}) => {
16+
setHeadComponents([
17+
<link
18+
key="favicon"
19+
rel="icon"
20+
type="image/png"
21+
href="/icons/icon-192.png"
22+
/>,
23+
]);
24+
};
25+
726
export const wrapRootElement: GatsbySSR['wrapRootElement'] = ({ element }) => (
827
<StrictMode>
928
<Root>{element}</Root>

packages/snaps/simple-keyring/packages/site/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@
8686
"gatsby-plugin-svgr": "^3.0.0-beta.0",
8787
"gatsby-plugin-webfonts": "^2.3.2",
8888
"prettier": "^2.8.4",
89+
"raw-loader": "^4.0.2",
8990
"react-scripts": "^5.0.1",
9091
"rimraf": "^4.4.0",
9192
"typescript": "^4.9.5"
7.36 KB
Loading
23.6 KB
Loading

yarn.lock

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5500,6 +5500,7 @@ __metadata:
55005500
gatsby-plugin-svgr: "npm:^3.0.0-beta.0"
55015501
gatsby-plugin-webfonts: "npm:^2.3.2"
55025502
prettier: "npm:^2.8.4"
5503+
raw-loader: "npm:^4.0.2"
55035504
react: "npm:^18.2.0"
55045505
react-dom: "npm:^18.2.0"
55055506
react-helmet: "npm:^6.1.0"

0 commit comments

Comments
 (0)