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

Fully static export #5485

Closed
wants to merge 4 commits into from
Closed

Fully static export #5485

wants to merge 4 commits into from

Conversation

jepser
Copy link
Contributor

@jepser jepser commented Oct 20, 2018

Enable fully static export by adding the property to the configuration object.

module.exports = {
  staticMarkup: true
}

@sebastiandedeyne
Copy link

Have in mind that getInitialProps won't be called

What's the reasoning behind this? Can't it be run during export?

@jepser
Copy link
Contributor Author

jepser commented Oct 27, 2018

Probably I need to be clearer, @sebastiandedey by setting staticMarkup to true, instead of renderToString in the export, it will run renderToStaticMarkup, so if you do client routing, it won't work as expected (running getInitalProps).

@timneutkens
Copy link
Member

So there are a few things that come to mind:

  • This PR only implements staticMarkup for next export, it should also work in development / production mode
  • staticMarkup doesn't make it immediately clear what this option does
> Have in mind that `getInitialProps` won't be called and all React bindings won't work. This will be a only html/css export.

Instead of saying getInitialProps won't be called, which is not completely true as we call it on next export, this would probably be a better explanation:

When enabling staticMarkup mode no script tags will be included in the rendered HTML, this is useful when creating a completely static application with no runtime.

@jepser
Copy link
Contributor Author

jepser commented Nov 7, 2018

@timneutkens that makes sense, let me update the PR.

@pengshaosu
Copy link

pengshaosu commented Nov 22, 2018

So there are a few things that come to mind:

  • This PR only implements staticMarkup for next export, it should also work in development / production mode
  • staticMarkup doesn't make it immediately clear what this option does
> Have in mind that `getInitialProps` won't be called and all React bindings won't work. This will be a only html/css export.

Instead of saying getInitialProps won't be called, which is not completely true as we call it on next export, this would probably be a better explanation:

When enabling staticMarkup mode no script tags will be included in the rendered HTML, this is useful when creating a completely static application with no runtime.

if only disable getInitialProps when call on SSR, the client side still working. how can configure?

@pengshaosu
Copy link

@

Enable fully static export by adding the property to the configuration object.

module.exports = {
  staticMarkup: true
}

this useful function is still not working/ok now?

@timneutkens
Copy link
Member

That's what an open pull-request means yes.

@jepser jepser force-pushed the fully-static-export branch from c33a23f to fbdad6a Compare November 30, 2018 14:02
@timneutkens
Copy link
Member

I'm going to close this PR, feel free to open a new one with my feedback taken into account: #5485 (comment)

@jepser
Copy link
Contributor Author

jepser commented Dec 11, 2018

Sure, I'm working on that, HMR breaks as removing some scripts that are not needed when removing React, so I'm still working on solving that issue.

I saw staticMarkup property is under next-server as a flag, do you know that served the same purpose because I don't see any example? @timneutkens

@timneutkens
Copy link
Member

Basically I want to deprecate / remove staticMarkup as we can implement other solutions for this issue that are potentially better, eg allowing the user to not load scripts or something.

@goldo
Copy link

goldo commented Dec 29, 2018

I'm also looking for a feature like this!
For now I've forked next.js only for something that looks a bit like:
#5102

@timneutkens can you tell me more about your idea ? I'd love to help and make a PR!

@lock lock bot locked as resolved and limited conversation to collaborators Dec 29, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants