gethypervisual / gridsome-plugin-netlify-cms

Gridsome.js plugin to include Netlify CMS
Other
15 stars 9 forks source link

CMS not showing up on site deployed to Netlify without providing a custom index.html in the cms folder #17

Closed tonyketcham closed 4 years ago

tonyketcham commented 4 years ago

I've followed the guide and played around with deployment on Netlify to no avail. When the CMS is working with my custom widgets .js file locally, I'm either a) unable to get the CMS to show up at all in deployment or b) unable to have it recognize my custom widgets.

If I follow the official Gridsome guide, adding an index.html to the cms folder with the config proposed there fails to reference my index.js. Leaving it out and setting those routes in the Gridsome config is the only thing that worked for me in development, however that index.html is successfully auto-generated by Gridsome.

Testing gridsome build locally gives this:

image

On deployment, routes like puerh.netlify.app/about work, but puerh.netlify.app/cms gives a 404. I generated a sitemap on the deployed site via Netlify, and it's not registering the cms index.html route at all:

<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:news="http://www.google.com/schemas/sitemap-news/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:mobile="http://www.google.com/schemas/sitemap-mobile/1.0" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" xmlns:video="http://www.google.com/schemas/sitemap-video/1.1">
<url>
<loc>https://<example>.netlify.app/404</loc>
<lastmod>2020-11-17T21:16:59Z</lastmod>
<changefreq>weekly</changefreq>
<priority>0.8</priority>
</url>
<url>
<loc>https://<example>.netlify.app/</loc>
<lastmod>2020-11-17T21:16:58Z</lastmod>
<changefreq>weekly</changefreq>
<priority>0.8</priority>
</url>
<url>
<loc>https://<example>.netlify.app/404</loc>
<lastmod>2020-11-17T21:16:58Z</lastmod>
<changefreq>weekly</changefreq>
<priority>0.8</priority>
</url>
<url>
<loc>https://<example>.netlify.app/about</loc>
<lastmod>2020-11-17T21:16:58Z</lastmod>
<changefreq>weekly</changefreq>
<priority>0.8</priority>
</url>
</urlset>

Here's the relevant part of my gridsome.config.js:

    {
      use: 'gridsome-plugin-netlify-cms',
      options: {
        modulePath: `src/cms/index.js`,
        configPath: `src/cms/config.yml`,
        publicPath: `/cms`,
        htmlTitle: `Tea CMS`,
      },
    },

...and my src directory:

image

I'm able to access everything w/ my custom widgets & config just fine locally on gridsome develop. Also, on Netlify I do have it correctly set to deploy the site from dist. The deploy logs show no errors either.

Happy to provide any more info to help get this resolved! It may just be a silly overlook on my part haha

FWIW, I did notice that after the build phase, the cms folder doesn't pop up until after I refresh the directory in VS Code, whereas everything else auto-pops up when the build phase says it's completed.

tonyketcham commented 4 years ago

If anyone would like to take a more in-depth look to see if I've done something wrong as far as setting the CMS up for deployment, it's in this repo: https://github.com/tonyketcham/puerh.wtf

Perhaps I need to set up a netlify.toml file to point towards the CMS? Although I'm not sure where it may be hiding on their end since gridsome build plops it in dist just like everything else. My build script on Netlify is just set to gridsome build as well.

tonyketcham commented 4 years ago

I just downloaded a zip of the deployed site files on Netlify and the cms folder isn't in there at all even though gridsome build creates it locally.

tobymarsden commented 4 years ago

Hey @tonyketcham,

You can use the debug option to see what's going on to cause the CMS not to be built, e.g.:

    {
      use: 'gridsome-plugin-netlify-cms',
      options: {
        modulePath: `src/cms/index.js`,
        configPath: `src/cms/config.yml`,
        publicPath: `/cms`,
        htmlTitle: `Tea CMS`,
        debug: true
      },
    }

When enabling this and building your repo, I see this:

ERROR in ./src/cms/index.js
Module not found: Error: Can't resolve 'uuid/v4' in '/Users/toby/Code/puerh.wtf/src/cms'

You may want to use this inside src/cms/index.js:

import {v4 as uuid} from 'uuid';
tonyketcham commented 4 years ago

Hey @tobymarsden, can I buy you a coffee or tea?

You've done it and it was so simple haha

tobymarsden commented 4 years ago

@tonyketcham to be fair debug is undocumented ;-)

tonyketcham commented 4 years ago

@tobymarsden any way I can help with the documentation? Would love to give back

tonyketcham commented 4 years ago

@tobymarsden I created a PR 😊 #18