diff --git a/gatsby-node.ts b/gatsby-node.ts index b2e93eb09..d56b6378b 100644 --- a/gatsby-node.ts +++ b/gatsby-node.ts @@ -1,4 +1,5 @@ import type { GatsbyNode } from 'gatsby' +import webpack from 'webpack' import { createExif } from './gatsby/createExif' import { createMarkdownFields } from './gatsby/createMarkdownFields' import { @@ -158,14 +159,22 @@ export const onPostBuild: GatsbyNode['onPostBuild'] = async ({ graphql }) => { return Promise.resolve() } -export const onCreateWebpackConfig: GatsbyNode['onCreateWebpackConfig'] = ({ - actions -}) => { - actions.setWebpackConfig({ - resolve: { - fallback: { - util: false +export const onCreateWebpackConfig: GatsbyNode['onCreateWebpackConfig'] = + async ({ actions }) => { + actions.setWebpackConfig({ + plugins: [ + new webpack.NormalModuleReplacementPlugin(/node:/, (resource) => { + resource.request = resource.request.replace(/^node:/, '') + }) + ], + resolve: { + fallback: { + util: false, + crypto: false, + path: false, + process: false, + url: false + } } - } - }) -} + }) + }