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 #6159

wants to merge 24 commits into
base: dev


Copy link

commented Jul 30, 2019

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)


Introducing a target option in nuxt.config.js, available values:

  • 'server' (default)
  • 'serverless'
  • 'static'

I also add the information in the Nuxt.js banner:
Screenshot 2019-07-31 at 17 31 24

Add in the Vue app + update process.static to use target === 'static' so it works in dev mode.

  • With CLI: nuxt <command = dev> <dir = '.'> [--target='server']

This option will allow to:

  • static: Enhance the developer experience when running nuxt dev:
    • Remove req & res from context
    • Fallback to client-side on 404 / error / redirect
    • Warn when using serverMiddleware and advise using them via modules.
    • Dissociate nuxt build & nuxt generate -> creating nuxt export to only generate routes
    • Generate a payload for not-excluded routes + EXPORT_TIME (if generate.static = true)
    • Crawl every dynamic pages (if generate.crawler = true)
    • Handle Page.static = false or $nuxt.isPreview
  • server: Expose a .nuxt/dist/server.js to start Nuxt in production with a script (ie: PM2, etc)
  • serverless: Expose a .nuxt/dist/serverless.js to start Nuxt in Serverless environements


  • 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.
Atinux and others added 9 commits Jul 30, 2019

This comment has been minimized.

Copy link

commented Jul 30, 2019

Codecov Report

Merging #6159 into dev will decrease coverage by 45.32%.
The diff coverage is 24%.

Impacted file tree graph

@@             Coverage Diff             @@
##              dev    #6159       +/-   ##
- Coverage   95.78%   50.46%   -45.33%     
  Files          80       82        +2     
  Lines        2659     2685       +26     
  Branches      684      692        +8     
- Hits         2547     1355     -1192     
- Misses         96     1027      +931     
- Partials       16      303      +287
Flag Coverage Δ
#e2e 100% <ø> (ø) ⬆️
#fixtures 50.46% <24%> (-0.31%) ⬇️
#unit ?
Impacted Files Coverage Δ
packages/config/src/config/modes.js 100% <ø> (ø) ⬆️
packages/vue-app/src/index.js 0% <ø> (ø) ⬆️
packages/cli/src/utils/config.js 0% <ø> (-96.67%) ⬇️
packages/config/src/config/_common.js 100% <ø> (ø) ⬆️
packages/generator/src/generator.js 0% <0%> (-100%) ⬇️
packages/vue-renderer/src/renderer.js 62.69% <0%> (-31.62%) ⬇️
packages/webpack/src/builder.js 48.93% <0%> (-43.62%) ⬇️
packages/cli/src/commands/index.js 0% <0%> (-11.12%) ⬇️
packages/cli/src/utils/banner.js 0% <0%> (-100%) ⬇️
packages/cli/src/commands/build.js 0% <0%> (-86.37%) ⬇️
... and 66 more

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 cb22d84...016806b. Read the comment docs.

packages/vue-renderer/src/renderer.js Outdated Show resolved Hide resolved
packages/webpack/src/config/base.js Outdated Show resolved Hide resolved
Atinux and others added 10 commits Jul 31, 2019
Update packages/vue-renderer/src/renderer.js
Co-Authored-By: Alexander Lichter <>

@nuxt nuxt deleted a comment from codecov-io Aug 2, 2019


This comment has been minimized.

Copy link

commented Aug 2, 2019

This looks really interesting. One question. What is the difference between static and serverless?

As I understand new modes are more or less similar to the following:

  • generate spa= serverless
  • generate universal = static
  • build spa/universal = server

Or did I miss the point?


This comment has been minimized.

Copy link
Member Author

commented Aug 2, 2019

Hey @husayt

Target is directly linked to the platform you want to host your Nuxt.js App, by default, it's server and is a normal node.js server with SSR.

  • server: Normal node.js hosting (Heroku, Amazon EC2, etc)
  • serverless: Serverless hosting (Now V2, AWS Lambda, Google Cloud Functions, etc)
  • static: Static/CDN hosting (Netlify, GitHub Pages,, Amazon S3, etc)

They mainly differs when running nuxt build, so Nuxt.js knows what kind of hosting platform you are aiming at :)

packages/config/src/options.js Outdated Show resolved Hide resolved
packages/core/src/module.js Show resolved Hide resolved
packages/vue-app/template/server.js Show resolved Hide resolved
packages/generator/src/generator.js Show resolved Hide resolved
@pi0 pi0 referenced this pull request Aug 5, 2019

@Atinux Atinux added this to To do in Nuxt v2.9 Aug 6, 2019

@Atinux Atinux self-assigned this Aug 6, 2019

@Atinux Atinux moved this from To do to In progress in Nuxt v2.9 Aug 6, 2019

Copy link

left a comment

If you approve the description changes we should probably also review the docs

packages/generator/src/generator.js Show resolved Hide resolved

export default {
name: 'export',
description: 'Export a static generated web application',

This comment has been minimized.

Copy link

pimlie Aug 8, 2019


From just reading the description of the generate vs export command it isnt really clear what the difference is I believe (for an outsider).

export: Export a static generated web application
generate: Generate a static web application (server-rendered)

Maybe it'd be better to avoid using the word 'generate' for export as the term export already implies that, something like:

Suggested change
description: 'Export a static generated web application',
description: 'Export a fully static web application',

Then we could also update the description of the generate command to: Generate a statically prerendered web application which would be more in line with Vue's ssr/prerender description?

This comment has been minimized.

Copy link

pi0 Aug 8, 2019


I believe new command is to avoid breaking changes and something better for name. Being fullStatic or not can be an option for nuxt3

This comment has been minimized.

Copy link

Atinux Aug 8, 2019

Author Member

Indeed, nuxt export is planned to be the new command to export (and will activate by default the full static option), nuxt generate will be deprecated since it also run the build which nuxt export does not.

@Atinux Atinux removed this from In progress in Nuxt v2.9 Aug 9, 2019

@Atinux Atinux added this to In progress in Nuxt v2.10 Aug 9, 2019

@Atinux Atinux referenced this pull request Sep 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
7 participants
You can’t perform that action at this time.