shellscape / webpack-manifest-plugin

webpack plugin for generating asset manifests
MIT License
1.44k stars 185 forks source link

webpack4 splitChunks: 'all' support #133

Closed wangzuo closed 6 years ago

wangzuo commented 6 years ago

For the following config in webpack4,

  optimization: {
    splitChunks: {
      chunks: 'all'
    },
    runtimeChunk: true
  }

In the webpack output stats, there is a list of files needed for each entrypoint like

Entrypoint about = runtime~about-b126ba8d5183247aa513.js vendors~about~home-bf6fa999743882049ea0.js about-f2320ebef52984b8b8a2.js
Entrypoint home = runtime~home-6b634e8923dcf64c8687.js vendors~about~home-bf6fa999743882049ea0.js static/css/home.3a775e54.chunk.css home-3a775e546f2420ba6807.js static/css/home.3a775e54.chunk.css.map

I am wondering is there any way to support this format in manifest plugin output?

mastilver commented 6 years ago

Can you give us the actual and expected manifest?

I would think we support that, if not then that's an issue

wangzuo commented 6 years ago

I would expect a manifest file with entrypoint support like

"about.js": ["/packs/runtime~about-b126ba8d5183247aa513.js", "/packs/vendors~about~home-bf6fa999743882049ea0.js", "/packs/about-f2320ebef52984b8b8a2.js"],

instead of

{
  "runtime~about.js": "/packs/runtime~about-b126ba8d5183247aa513.js",
  "vendors~about~home.js": "/packs/vendors~about~home-bf6fa999743882049ea0.js",
  "about.js": "/packs/about-f2320ebef52984b8b8a2.js"
}
mastilver commented 6 years ago

Oh, I see. I'm afraid it's the correct behaviour

Did you try using https://github.com/danethurber/webpack-manifest-plugin#hooks-options ?

wangzuo commented 6 years ago

Thanks, guess thats what i want

mastilver commented 6 years ago

Let me know if you think a new options should be added to make that job easier

wangzuo commented 6 years ago

I dont think its possible with current implementation, the entrypoints available in new compilation.chunkGroups. The following is my implementation to add an extra entrypoints field in the manifest file, wondering someone find a better way for this feature.

    manifest.entrypoints = compilation.chunkGroups.reduce((result, group) => {
      const files = new Set();
      group.chunks.forEach(chunk => {
        chunk.files.forEach(file => {
          files.add(`${chunk.name}${extname(file)}`);
        });
      });
      result[group.name] = Array.from(files);
      return result;
    }, {});
mastilver commented 6 years ago

I will try to have a look when I have time, a failing test would help a lot

bf commented 6 years ago

Has this issue been resolved? @wangzuo could you share an example how you fixed it?

wangzuo commented 6 years ago

@bf webpack-assets-manifest works

bf commented 6 years ago

Thank you. In the meantime I have adapted WebpackSplittingManifestPlugin to work with webpack 4 and our specific AggressiveSplittingPlugin use case.

FranklinWhale commented 6 years ago

Is there any update on this issue? I think this plugin should support entrypoints like webpack-assets-manifest.

xoneill commented 6 years ago

please fix

FranklinWhale commented 6 years ago

@wangzuo Why have you closed this issue?

FranklinWhale commented 6 years ago

@mastilver I think this remains a valid issue to be fixed/implemented. Would you re-open it?

timkelty commented 5 years ago

Is the solution here simply to use https://github.com/webdeveric/webpack-assets-manifest, or is there any update?

nsunga commented 5 years ago

possible solution for the code splitting: https://github.com/danethurber/webpack-manifest-plugin/issues/181