create-nuxt-app icon indicating copy to clipboard operation
create-nuxt-app copied to clipboard

[enhancement] Make `target: "static"` the Default Option

Open lihbr opened this issue 5 years ago • 3 comments

Is your feature request related to a problem? Please describe.

According to Vue Telemetry there are now more static websites than non-static websites:

  • Static: https://api.vuetelemetry.com/showcases/count?framework.slug=nuxtjs&isStatic=true
  • Non-static: https://api.vuetelemetry.com/showcases/count?framework.slug=nuxtjs&isStatic=false

And if you look without a framework (not sure how this one is relevant though):

  • Static: https://api.vuetelemetry.com/showcases/count?isStatic=true
  • Non-static: https://api.vuetelemetry.com/showcases/count?isStatic=false

Since prompts seem to be "opinionatedly sorted" (Yarn is over NPM, Jest over AVA, etc.), I think it'll be ok to prioritize the static option over the server one too (since that also seems to be the general tendency of what people are going for?)

Describe the solution you'd like

Making target: "static" the default selected option within the prompts: https://github.com/nuxt/create-nuxt-app/blob/master/packages/create-nuxt-app/lib/prompts.js#L105-L106

Describe alternatives you've considered

I checked for presets flag or similar but as Debbie pointed out it'll be cool to have presets within the create-nuxt-app CLI. Perhaps at the end of the prompts asking if we want to save current answers as a preset for future usage locally and at the next runs if it detects presets ask if we want to use one of them instead? Just throwing ideas ^^'

Additional context

I'm sorry for this silly issue, this all started as a joke, but I'd also really like to be able to spam my enter key also ☺️

Cheers!

lihbr avatar Dec 04 '20 13:12 lihbr

Thanks for detailed issue as always @lihbr <3

Memorizing selected options would be awesome! (can be easily implemented with fs-memo)

Also for default option, makes sense based on stats (i've to also verify with nuxt-telemetry stats). Just worried documentation is prepared for starters since features like ssrContext and query are not available (and current docs focus is on universal mode)

Also FYI, With nuxt3, there is probably no more mode/ssr and target options since it is hybrid by default (with a hook similar to useStatic) for static pages.

pi0 avatar Dec 04 '20 13:12 pi0

Hey Pooya, thanks for the quick feedback!

Makes sense with the doc focusing on universal mode indeed, let me know if you agree on something! Happy to work on a PR using fs-memo, or to just switch the default option~

This is like priority: -1 so no hurry 🙂

lihbr avatar Dec 04 '20 14:12 lihbr

Thanks for the PR @lihbr

Like Pooya mentionned we would need at least to update the documentation to add some warnings for what is not available when `target: 'static':

  • https://nuxtjs.org/docs/2.x/internals-glossary/context#query
  • https://nuxtjs.org/docs/2.x/internals-glossary/context#req

(I think we should say Not available via static target instead of just nuxt generate)

We will also need to add a runtime warning in the console when trying to access these keys in static target.

When this will be done, I am more than happy to make it the default!

atinux avatar Dec 04 '20 14:12 atinux