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

Allow to only generate a json with assets list #982

Closed
caub opened this issue Jun 19, 2018 · 6 comments
Closed

Allow to only generate a json with assets list #982

caub opened this issue Jun 19, 2018 · 6 comments

Comments

@caub
Copy link

caub commented Jun 19, 2018

I'm wondering if I should add a chunksSortFile option, and allow to pass filename: null so that the ouput of this plugin is a simple json containing js and css sorted list

Or should it be another plugin, sharing the same sorting logic: https://github.com/caub/webpack-plugin-assets

The goal is to only have this assets list from the build, and handle the html templating independently

@jantimon
Copy link
Owner

jantimon commented Jun 20, 2018

You can already do that using a template and setting inject:false.
Please note that we are changing from getStats for performance reasons

@caub
Copy link
Author

caub commented Jun 20, 2018

@jantimon Ah right, thanks a lot for telling https://github.com/jantimon/html-webpack-plugin/blob/webpack-4/index.js#L118

There's another apporach I've taken too, it's to use ManifestPlugin and add the assets ordering there: shellscape/webpack-manifest-plugin#93 (comment)
then I just filter for the \.(js|css)$ assets to know the ordered assets

@caub
Copy link
Author

caub commented Jun 20, 2018

Concerning what you said

You can already do that using a template and setting inject:false

I'm not sure I can do it fully, except if I can export the assetJson object

my end goal is to have a template like (I named it index.html.js)

module.exports = ({
  htmlWebpackPlugin: {options = {}} = {},
  jsAssets = [],
  cssAssets = [],
  injectedEnv = options.injectedEnv || '',
  nonce = '',
  ..
}) => `<!DOCTYPE html><html> .... `

I don't use any index.html, in dev mode I can still use html-webpack-plugin, with inject: false or true actually.

in production mode, I want more flexibility (the injectedEnv, and other dynamic things (like nonce attributes)), and serve this template from a server

@jantimon
Copy link
Owner

You can use the template parameters similar to this example:

https://github.com/jantimon/html-webpack-plugin/tree/master/examples/template-parameters

Instead of using an object you would have to pass a function

@caub
Copy link
Author

caub commented Jun 20, 2018

@jantimon awesome work, sincere thanks for that

I see that webpack4 is providing the ordered stuff now, great

I still see some dups in the assets, eg: ..., "/static/js/vendors.5c7232b4.js", ..., "/static/js/runtime~main.87700e36.js", "/static/js/vendors.5c7232b4.js", ... (twice this vendor) but very easy to Set/unique them

@lock
Copy link

lock bot commented Jul 20, 2018

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Jul 20, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants