If I configure gridsome to generate pages from templates for a collection of nodes using the templates property of gridsome.config.js, but a pathname to the component template points to a missing file, gridsome simply skips generating those pages, and continues building without flagging an error.
The pages API seems to fail as expected for a missing component, so the issue isn't in the pages code.
In a gridsome project with a collection called post, and component template src/templates/Post.vue, add to gridsome.config.js:
templates: {
post: [
{
name: 'name1',
path: '/blah1/:uid',
component: './src/templates/Post.vue'
},
{
name: 'name2',
path: '/blah2/:uid',
component: './src/templates/NonExistentTemplate.vue'
}
]
}
Then run:
$ gridsome build
The build should have failed with an error like:
Error: Could not find component <blah>/src/templates/NonExistentTemplate.vue.
Build completed, with pages in /blah1 built, but no pages in /blah2.
Libs:
- gridsome version: 0.7.4
- @gridsome/cli version: 0.2.3
Platform:
- Node version: v10.16.3
- Platform: macOS Sierra 10.12.6
The idea was that you can add the templates without restarting gridsome develop. But I agree that it's better to throw an error if the files are missing. We can change it to keep the current behavior in development but fail when running build instead for now.
Most helpful comment
The idea was that you can add the templates without restarting
gridsome develop. But I agree that it's better to throw an error if the files are missing. We can change it to keep the current behavior in development but fail when runningbuildinstead for now.