Gridsome: Gridsome silently ignores missing component files when generating template pages

Created on 24 Sep 2019  路  1Comment  路  Source: gridsome/gridsome

Description

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.

Steps to reproduce

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

Expected result

The build should have failed with an error like:
Error: Could not find component <blah>/src/templates/NonExistentTemplate.vue.

Actual result

Build completed, with pages in /blah1 built, but no pages in /blah2.

Environment


Libs:
- gridsome version: 0.7.4
- @gridsome/cli version: 0.2.3

Platform:
- Node version: v10.16.3
- Platform:  macOS Sierra 10.12.6

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 running build instead for now.

>All comments

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tomtev picture tomtev  路  3Comments

mattbrailsford picture mattbrailsford  路  3Comments

NickStees picture NickStees  路  3Comments

martifenosa picture martifenosa  路  3Comments

ghost picture ghost  路  3Comments