Skip to content

Request: Add support for a 'render-time' method to manipulate locals #121

Description

@jahredhope

Isolating Webpack Logic

Currently this plugin passes the webpackStats object directly to the render function.
This can be helpful when assets is not enough information to render.

However it can result in webpack specific logic being added to the render function. For example:

  const publicPath = webpackStats.compilation.outputOptions.publicPath;
  const clientJsEntry = assetsByChunkName.main
    .filter(value => value.match(/\.js/))
    .map(value => `${publicPath}${value}`)[0];
  const clientCssEntry = assetsByChunkName.main
    .filter(value => value.match(/\.css$/))
    .map(value => `${publicPath}${value}`)[0];

By adding a runtime transform function the logic required to pull data out of webpackStats object can be isolated to the webpack configuration.
This may be particularly useful for tools that wrap this plugin, which may choose to use the function to normalize the parameters being given to their consumer's render function.

'Render-time' build info

Separately, information required to render the HTML may not be available when the configuration is first built.
A render-time transform function will allow values created during the build process (such as peer webpack configurations) to be injected into the render process.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions