Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v2] Using gatsby-plugin-netlify-cms in v2 doesn't work correctly #6048

Closed
richtera opened this issue Jun 20, 2018 · 4 comments
Closed

[v2] Using gatsby-plugin-netlify-cms in v2 doesn't work correctly #6048

richtera opened this issue Jun 20, 2018 · 4 comments
Labels
help wanted Issue with a clear description that the community can help with. type: bug An issue or pull request relating to a bug in Gatsby

Comments

@richtera
Copy link

Description

I am using gatsby@next and I am trying to get the netlify-cms plugin to work.
Using the 1.0 plugin doesn't get inserted into webpack and the index.html in admin doesn't get build.
Using the 2.x plugin causes a error when executing the onCreateWebpackConfig
The code looks like this

exports.onCreateWebpackConfig = ({ config, stage }, { modulePath }) => {
  config.merge({
    entry: {
      cms: [`${__dirname}/cms.js`, modulePath].filter(p => p),
    },
    plugins: plugins(stage),
  })

  module(config, stage)

  return config
}

And this seems to be an older pre final 2 api. The new API uses actions and not config, state and modulePath.

Describe the issue that you're seeing.

The error is:

error UNHANDLED EXCEPTION


  TypeError: Cannot read property 'merge' of undefined
  
  - gatsby-node.js:91 Object.exports.onCreateWebpackConfig
    [gatsby-starter-netlify-cms]/[gatsby-plugin-netlify-cms]/gatsby-node.js:91:10
  
  - api-runner-node.js:104 runAPI
    [gatsby-starter-netlify-cms]/[gatsby]/dist/utils/api-runner-node.js:104:37
  
  - api-runner-node.js:173 mapSeries
    [gatsby-starter-netlify-cms]/[gatsby]/dist/utils/api-runner-node.js:173:25

Steps to reproduce

Configure a 2.x gatsby site with the 2.x version of the gatsby-plugin-netlify-cms plugin.

Expected result

It would generate the appropriate index.html file in admin.

Actual result

It just errs out during the build

Environment

MacOS, node v9.11.1, npm v6.1.0, yarn v1.7.0

System:
OS: macOS High Sierra 10.13.5
CPU: x64 Intel(R) Core(TM) i7-7920HQ CPU @ 3.10GHz
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 9.11.1 - ~/.nvm/versions/node/v9.11.1/bin/node
Yarn: 1.7.0 - /usr/local/bin/yarn
npm: 6.1.0 - ~/.nvm/versions/node/v9.11.1/bin/npm
Browsers:
Chrome: 67.0.3396.87
Firefox: 60.0.1
Safari: 11.1.1
npmPackages:
gatsby: next => 2.0.0-beta.2
gatsby-image: next => 2.0.0-beta.1
gatsby-plugin-emotion: next => 2.0.0-beta.1
gatsby-plugin-manifest: next => 2.0.2-beta.1
gatsby-plugin-netlify: next => 2.0.0-beta.1
gatsby-plugin-netlify-cms: next => 2.0.0-beta.1
gatsby-plugin-offline: next => 2.0.0-beta.1
gatsby-plugin-react-helmet: next => 3.0.0-beta.1
gatsby-plugin-sharp: next => 2.0.0-beta.1
gatsby-source-filesystem: next => 2.0.1-beta.1
gatsby-transformer-remark: next => 2.1.1-beta.1
gatsby-transformer-sharp: next => 2.1.1-beta.1
gatsby-transformer-yaml: next => 2.1.1-beta.1
npmGlobalPackages:
gatsby: 2.0.0-beta.1

File contents (if changed)

gatsby-config.js: N/A
package.json: N/A
gatsby-node.js: N/A
gatsby-browser.js: N/A
gatsby-ssr.js: N/A

@richtera
Copy link
Author

The repo has a slightly newer version of the plugin but that still doesn't work. It's assuming setWebpackConfig returns a webpack config object.

@ekafyi
Copy link
Contributor

ekafyi commented Jun 21, 2018

Hi, I'm having the same problem with gatsby@next and gatsby-plugin-netlify-cms.

What I tried:

  • Installed dependencies as per package.json of gatsby-starter-netlify-cms repo
  • Added index.html to admin directory
  • Added branch: master to config.yml as per Netlify CMS docs

I'm a beginner so I'm not sure how/where to check the webpack or babel config.

Would love to hear if there is any workaround available, thanks.

@richtera
Copy link
Author

richtera commented Jun 21, 2018

@ekaoddlass Currently the plugin only seems to partially work even with v1. I am trying to get it work with v2. I added a PR to make it work in develop but not production builds. PR is #6056

@m-allanson m-allanson added type: bug An issue or pull request relating to a bug in Gatsby help wanted Issue with a clear description that the community can help with. labels Jun 22, 2018
@erquhart
Copy link
Contributor

Closed in #6356.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Issue with a clear description that the community can help with. type: bug An issue or pull request relating to a bug in Gatsby
Projects
None yet
Development

No branches or pull requests

4 participants