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

feat: add exclude regex array for generated pages #4754

Merged
merged 3 commits into from Jan 16, 2019

Conversation

manniL
Copy link
Member

@manniL manniL commented Jan 13, 2019

This PR will add a property called generate.exclude. It accepts an array of regular expressions and will prevent generation of routes matching them. The routes will still be accessible when generate.fallback is used.

Use cases

  • Having routes like /admin in the Nuxt app that don't need to be generated upfront but still need to be accessible
  • Modules like sitemap-module could use it as default for excluding routes in generate mode.

Usage

// nuxt.config.js
export default {
  // ...
  generate: {
    //...
    exclude: [/^\/admin/] // exclude every URL starting with "/admin"
  }
}

Testing

Testing this feature is a bit tricky because we never test that the generated fallback actually loads the routes in SPA mode. We only test that it has been generated correctly here.

Types of changes

  • Bug fix (a non-breaking change which fixes an issue)
  • New feature (a non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly. (PR: #)
  • I have added tests to cover my changes (if not applicable, please state why)
  • All new and existing tests are passing.

@manniL
Copy link
Member Author

manniL commented Jan 13, 2019

image

@codecov-io
Copy link

codecov-io commented Jan 14, 2019

Codecov Report

Merging #4754 into dev will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##              dev    #4754      +/-   ##
==========================================
+ Coverage   90.21%   90.21%   +<.01%     
==========================================
  Files          67       67              
  Lines        2289     2290       +1     
  Branches      568      568              
==========================================
+ Hits         2065     2066       +1     
  Misses        201      201              
  Partials       23       23
Impacted Files Coverage Δ
packages/config/src/config/_common.js 100% <ø> (ø) ⬆️
packages/generator/src/generator.js 91.42% <100%> (+0.08%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5ec0c8d...b884218. Read the comment docs.

@manniL manniL requested review from pi0 and clarkdo January 14, 2019 10:17
Copy link
Member

@pi0 pi0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. BTW do you mind adding a small test for it? @manniL

@manniL
Copy link
Member Author

manniL commented Jan 14, 2019

@pi0 That might be a bit problematic as I can only test that the file is not generated. I can't test if it can be correctly accessed through the fallback file. (see "Testing" in the PR text).

Would that suffice?

@pi0
Copy link
Member

pi0 commented Jan 16, 2019

@manniL Seems OK 👍😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants