Skip to content

Compile to static html but allow some custom JS to be proccessed #476

@jannisg

Description

@jannisg

I'm just trying to move my static html workflow away from Ruby based tools like Middleman to NodeJS based tools like Gatsby and I am having trouble trying to work out if there is a way to:

  1. Compile React modules to static html files (supported by gatsby using the noProductionJavascript option)
  2. Allow some JavaScript to still make it through the compile pipeline but still end up with a non-react dependent static html output overall.

Use case being that I occasionally do a pretty basic design to HTML conversion job for ad agencies so they expect me to deliver:

  1. Static .html files for each "template" they had designed
  2. Within their templates if anything requires JavaScript (modals, overlays, etc), those bits be supported and shipped as part of a JS bundle for the static app.
  3. Static assets (fonts, images, etc) be compressed
  4. Static output has usable hrefs that they can click through to navigate the templates
  5. The compiled HTML source should be neatly formatted and uncompressed

I believe Gatsby natively supports 1, 3 and 4. Point 5 is probably doable too but I am struggling to understand if 2 is possible as the noProductionJavascript seems to strip all JS out so I am not sure if I could for example have a file that is still being bundled containing custom app JS but not any of the react stuff.

Would be great to hear if this use case is supported somehow already or if I am perhaps looking at the wrong too for what I need to do :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions