renvrant / gatsby-mdx-netlify-cms-starter

Gatsby-MDX with Netlify CMS. Support React components in your CMS editor!
MIT License
88 stars 46 forks source link

Netlify deploy failing #9

Closed zzrez closed 4 years ago

zzrez commented 4 years ago

Hi, I clicked the green Deploy to Netlify button, and it failed. In the Netlify control panel I then clicked to try Deploy again, with cache removal. Same result. In both cases this was the error message Netlify gave:- 5:23:23 PM: error "gatsby-plugin-netlify-cms" threw an error while running the onCreateWebpackConfig lifecycle: 5:23:23 PM: Module not found: Error: Can't resolve 'fs' in '/opt/build/repo/node_modules/@babel/core/lib/transformation' 5:23:23 PM: ModuleNotFoundError: Module not found: Error: Can't resolve 'fs' in '/opt/buil d/repo/node_modules/@babel/core/lib/transformation' A pity as I wanted to study the NetlifyCMS settings.

l3aconator commented 4 years ago

This is a hack but the issue is MDX run time, and you need to set node: { fs: 'empty' } in gatsby-confg.js. See here:

https://github.com/mdx-js/mdx/issues/913 https://github.com/webpack-contrib/css-loader/issues/447#issuecomment-285600014 https://github.com/gatsbyjs/gatsby/issues/10326#issue-388289647 <- this is the issue, but you need to modify the plugins config NOT your local config, they are separate. here is the hack below:

{
      resolve: `gatsby-plugin-netlify-cms`,
      options: {
        modulePath: `${__dirname}/src/cms/cms.js`, // for custom preview in the Netlify CMS
        customizeWebpackConfig: (config) => (config.node.fs = 'empty'),
      },
    }