-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
feat: options.target and full-static export #6159
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
Conversation
Codecov Report
@@ Coverage Diff @@
## dev #6159 +/- ##
=======================================
Coverage 70.86% 70.86%
=======================================
Files 88 88
Lines 3587 3587
Branches 974 974
=======================================
Hits 2542 2542
Misses 848 848
Partials 197 197
Continue to review full report at Codecov.
|
Co-Authored-By: Alexander Lichter <[email protected]>
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:
Or did I miss the point? |
Hey @husayt Target is directly linked to the platform you want to host your Nuxt.js App, by default, it's
They mainly differs when running |
Literally just came to as the same thing as @nilsnh :) |
@nilsnh @davidsneal With I have also checked for current nuxt.config: export default {
target: 'static',
generate: {
routes () {
return [{
route: '/',
payload: { foo: 'bar' }
}]
}
}
} pages/index.vue: export default {
asyncData ({ payload }) {
return {
payload
}
}
} dist/_nuxt/static/{version}/payload.js: __NUXT_JSONP__("/", {data:[{payload:{foo:"bar"}}],fetch:[],mutations:void 0}); |
Hi Team, I am trying this static generation. I see Lot of 404 on my console whenever subpage has slug which has space in it. open chrome inspect/devtools One more scenario: This post is linked to 6 categories, apart from one category rest 5 categories payload.js throws 404 error. Please let me know if you need more details on the same. |
Ok I have planned to change my backend data for categories list. But now I am stuck with querying :( how can i look for slug = 'ABC' in the below categories list/array. This categories will be present in all posts so I need get the subset of posts matching a particular slug.
Earlier I had categories as below, only values |
@rajesh-h Would you please kindly report this issue to nuxt/content and with proper repro? I will also try to reproduce and check the issue you mentioned about spaces :) |
Thank you @pi0. looks like json/netsed filter is not possible based on comments on this issue. If space issue is resolved, I can go back to my original design where keeping categories array as simple list. Please let me know if you want any input for the space issue. Thank you very much. |
Hello, Thank you so much for the static generation mode, I'm trying it through nuxt-edge, great job from the team ! In dev mode, it happens on each route change. In both modes, the route loads after the flash. Did you encouter this behaviour before ? EDIT: I was toying around the options. The weird flash only happened when I had |
@pi0 I am not sure its the issue with space :( . When you go down at this link - https://cscom-2019.web.app/category/cakes-more when more posts are getting loaded you will see lot of 404 for payload.js this behavior not observed on homepage. https://cscom-2019.web.app you can keep going down and load posts. Both have the same structure like load 10 posts initially then load further posts when you scroll down. Any lead to resolve this will be helpful. In case you want to refer: Side Question: Does the static site removes that nice animation of horizontal line page loading on top when you click on a link? |
Pages with pagination navigations with this "full-static" feature don't work by the way. I assume that it is a bug. The pagination works fine with Nuxt 2.12.2. |
@pi0 did you happen to see what might be causing 404 errors? any lead would be helpful. Functionally no problem, just that too much error on console. |
I am eager to test this out, but I have two questions:
|
@atinux GREAT work! Seems to work out of the box. Even with routes which are meant to be fetched from server. Page switching is waay faster now. However, I noticed my og:description is now "undefined". I am not sure if it is related to this pull through. I set og:description to |
One question though @atinux. I am curious, will this have any inital page speed / load time issues? How is the implementation done exactly? I really love the feature, and how fast it now switches pages, but we have a e-commerce platform with 5-6000 routes, so I am curious if this amount of pages will slow down initial page load speed. You can check here https://beta.thejewelleryroom.com vs https://thejewelleryroom.com |
Same issue over here, the following error flashes by when changing routes however no error is logged to the console.
I have it in dev and production mode while running in ssr mode. |
I'm finding a funny issue: Routes that return a 404 error still get statically rendered when using |
Why would you generate a route that returns 404? |
It's kind of a bug in my code (related to i18n and missing translated documents), but I can see some scenarios where the crawler can get confused and try to render a route that returns an error state - like, say, a route that comes from user input. Shouldn't Nuxt avoid statically rendering these routes and instead let the client-side code pick it up? Or, at least, shouldn't it statically render a 404 page? Right now it just falls back to the static SPA version of the page, which doesn't add much value. Funny enough; if you raise an exception, then the route doesn't get rendered (which is how I ultimately did the trick on my scenario). In any case, this is such a neat feature and I'm enjoying it so much! |
Normally if the crawler hits a page that render a 404, it will render the page with no ssr to let the client-side falling back |
@atinux I want to host the app in aws s3 and still want to load data from my API for the dynamic routes. is there a to disable reading the payload.js and read the API response? I can exclude the dynamic routes but aws s3 will return it as 404 status and can impact the Google indexing |
Types of changes
Description
Introducing a
target
option innuxt.config.js
, available values:'server'
(default)'static'
I also add the information in the Nuxt.js banner:

Add
process.target
in the Vue app + updateprocess.static
to usetarget === 'static'
so it works in dev mode.nuxt <command = dev> <dir = '.'> [--target='server']
This option will allow to:
static: Enhance the developer experience when running
nuxt dev
:req
&res
from contextnuxt build
&nuxt generate
-> creatingnuxt export
to only pre-render routesgenerate.static = true
)generate.crawler = true
)Page.static = false
or$nuxt.isPreview
$route.query
to be empty on SSR to mimicnuxt export
Check side effects of
created
vsbeforeCreate
forfetch
Checklist: