Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions data/onCreateNode/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
import { GatsbyNode, Node } from 'gatsby';

// Touch existing derived nodes on every build so Gatsby's stale-node GC
// does not delete them on warm restart. Derived nodes created via
// `createNode` from inside `onCreateNode` are not re-created when their
// parent File nodes are cached unchanged, so without this hook the
// ExampleFile nodes disappear between dev runs and `allExampleFile`
// returns undefined in createPages.
export const sourceNodes: GatsbyNode['sourceNodes'] = ({ actions, getNodesByType }) => {
const { touchNode } = actions;
getNodesByType('ExampleFile').forEach((node) => touchNode(node));
};

export const onCreateNode: GatsbyNode['onCreateNode'] = async ({
node,
actions: { createNode, createParentChildLink },
Expand Down
11 changes: 10 additions & 1 deletion gatsby-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,16 @@ const headerLinkIcon = `<svg aria-hidden="true" height="20" version="1.1" viewBo
export const plugins = [
'gatsby-plugin-postcss',
'gatsby-plugin-image',
'gatsby-plugin-sharp',
process.env.NODE_ENV === 'production'
? 'gatsby-plugin-sharp'
: {
resolve: 'gatsby-plugin-sharp',
options: {
defaults: {
formats: ['auto'],
},
},
},
'gatsby-transformer-yaml',
{
resolve: 'gatsby-transformer-sharp',
Expand Down
2 changes: 1 addition & 1 deletion gatsby-node.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export { createPages } from './data/createPages';
export { onCreateNode } from './data/onCreateNode';
export { onCreateNode, sourceNodes } from './data/onCreateNode';
export { onCreatePage } from './data/onCreatePage';
export { createSchemaCustomization } from './data/onCreateNode/create-graphql-schema-customization';
export { onCreateBabelConfig } from './gatsby-overwrite-config';
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@
"node": "^22.19.0"
},
"scripts": {
"develop": "export EDITOR_WARNINGS_OFF='true' && gatsby clean && gatsby develop",
"develop": "export EDITOR_WARNINGS_OFF='true' GATSBY_CPU_COUNT='physical_cores' GATSBY_EXPERIMENTAL_DEV_SSR='true' && gatsby develop",
"develop:clean": "export EDITOR_WARNINGS_OFF='true' GATSBY_CPU_COUNT='physical_cores' GATSBY_EXPERIMENTAL_DEV_SSR='true' && gatsby clean && gatsby develop",
"develop:env-setup": "cp .env.example .env.development",
"start": "yarn clean && yarn develop",
"edit": "unset EDITOR_WARNINGS_OFF && export ENABLE_GATSBY_REFRESH_ENDPOINT='true' && gatsby clean && gatsby develop",
"edit": "unset EDITOR_WARNINGS_OFF && export ENABLE_GATSBY_REFRESH_ENDPOINT='true' GATSBY_CPU_COUNT='physical_cores' GATSBY_EXPERIMENTAL_DEV_SSR='true' && gatsby develop",
"refresh": "curl -X POST http://localhost:8000/__refresh",
"build": "yarn clean && gatsby build --prefix-paths",
"build:cli": "tsc -p .",
Expand Down