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

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

Open
jahredhope opened this issue Mar 5, 2018 · 0 comments · May be fixed by #122
Open

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

jahredhope opened this issue Mar 5, 2018 · 0 comments · May be fixed by #122

Comments

@jahredhope
Copy link
Collaborator

jahredhope commented Mar 5, 2018

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.

@jahredhope jahredhope linked a pull request Mar 5, 2018 that will close this issue
@jahredhope jahredhope changed the title Request: Add support for a runtime method to manipulate locals Request: Add support for a 'render-time' method to manipulate locals Mar 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant