feat: Supply HTML Template for Playroom & Preview#189
feat: Supply HTML Template for Playroom & Preview#189alexbchr wants to merge 3 commits intoseek-oss:masterfrom
Conversation
|
This looks a lot more promising. Seeing this implemented raises a few questions around the ambiguity between the rendering of frames versus the whole document. For example if you need a font, or css from a CDN etc, these should be setup via the With that in mind, if we are thinking about reasons to access the top level document, a few questions come up:
|
To clarify the distinction between
No, here are other use cases I have and are solved by the HTML template:
For me, these pages are highly different, so I needed to have distinct elements on the 2 pages:
I preferred to separate both options for customizability. Should someone ever need the exact same layout for both, it can easily be done using the same file for both options.
2 possible outcomes here with current implementation:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title><%= htmlWebpackPlugin.options.title %></title>
</head>
<body>
</body>
</html> |
|
Yeah gotcha. I tend to agree that documentation is probably the only defence here. In terms of configuration changes, what are your thoughts on {
htmlTemplate: {
'/': './pathToMainTemplate.ejs',
'/preview': './pathToPreviewTemplate.ejs',
}
}May be more future proof and break the one-to-one route to template configuration. |
I like the idea of nesting the whole template configuration in a nested object. In fact this was how I did it upfront but since all other configuration don't have nested keys (from what I remember), I went with the "flat" way. What I first thought was going on with arbitrary keys, like this: {
htmlTemplate: {
'home': './pathToMainTemplate.ejs',
'preview': './pathToPreviewTemplate.ejs',
}
}However I dislike the term After much thought, I like the idea of using the path, but I feel this will need to be documented a bit more, as I fear this may cause confusion if used in conjunction with the |
|
@michaeltaranto Updated code to use new nested configuration with paths (paths act as constants, template value is not inferred dynamically from current path). Also updated documentation to reflect previous discussions. Also, just a comment here! When I started playing with Playroom, I found options quite self-explanatory and simple. However, some more advanced options, such as this one or I think it would be very useful (especially for newcomers), to have all options documented somewhere (in the Readme or a separate page) (in a table or something). Maybe only options that are considered as "advanced" would need such treatment, but I think it would still gain in clarity. |
Adds new
htmlTemplateandpreviewHtmlTemplateoptions in config, which receive a path to the HTML template used to render Playroom (and Preview).Sample usage:
If no template is provided, Playroom renders exactly as it did before this change.
Note: Template gets loaded by HtmlWebpackPlugin as mentioned in Readme. This way, we can leverage all the power of loaders or simply supply a simple
.htmlfile.I also extended
themedexample with the new options, for example usage.This will also fix issue #40.