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

[Question][V2] Paths of bundles #3842

Open
brillout opened this issue Nov 24, 2019 · 0 comments
Open

[Question][V2] Paths of bundles #3842

brillout opened this issue Nov 24, 2019 · 0 comments

Comments

@brillout
Copy link

In the context of SSR and SR (Static Rendering), I need bundles to be saved as follows.

// Static browser assets to be served

// https://example.com
pages/dist/staticDir/index.html
pages/dist/staticDir/bundle1.js
// https://example.com/about
pages/dist/staticDir/about.html
pages/dist/staticDir/bundle2.js
pages/dist/staticDir/style.css

// Bundles for server-side rendering

pages/dist/nodejs/Product.page.template.html
pages/dist/nodejs/Product.page.js

What's crucial here is that:

  • Some .html files are rendered at build-time and need to be saved in pages/dist/staticDir.
  • Some other HTML are rendered at request-time and the .html template need to be saved in a separate directory, e.g. pages/dist/nodejs/Product.page.template.html.

The directory pages/dist/staticDir contains all browser-side assets and needs to be served by the server.

Note that pages/dist/staticDir/about.html is fully rendered:

<html>
  <div id='react-root'>
    This is the content of an about page.
    I'm rendered at build-time!.
  </div>
</html>

Whereas pages/dist/nodejs/Product.page.template.html is only partly rendered:

<html>
  <div id='react-root'>
    !PAGE_VIEW_HTML
  </div>
</html>

At request-time, the Node.js server renders Product.page.js to HTML and replaces !PAGE_VIEW_HTML with the rendered HTML.

The practice to render some pages to HTML at build-time while other pages are rendered to HTML at request-time is a common practice in the SSR world. E.g. Next.js does that.

How can I achieve this with Parcel v2?

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

No branches or pull requests

2 participants