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

options.chunks can support more matching formats, such as: RegExp, Function #1319

Closed
zwlijun opened this issue Dec 10, 2019 · 6 comments
Closed
Labels

Comments

@zwlijun
Copy link

zwlijun commented Dec 10, 2019

Is your feature request related to a problem? Please describe.
In VUE, when I use multi-page mode, "chunks" are not injected into HTML.

Describe the solution you'd like
I checked the source code of the installation package and learned from the source code that the current filtering of chunks is an exact match. I hope I can improve the current method and add more matching methods, such as:

  filterChunks (chunks, includedChunks, excludedChunks) {
    return chunks.filter(chunkName => {
      // Skip if the chunks should be filtered and the given chunk was not added explicity
      if (Array.isArray(includedChunks) && includedChunks.indexOf(chunkName) === -1) { // chunks: Array
        return false;
      } else if (includedChunks instanceof RegExp) { // chunks: RegExp
        return includedChunks.test(chunkName);
      } else if (typeof includedChunks === 'function') { // chunks: Function
        return includedChunks(chunkName);
      }
      // if (Array.isArray(includedChunks) && includedChunks.indexOf(chunkName) === -1) {
      //   return false;
      // }

      // Skip if the chunks should be filtered and the given chunk was excluded explicity
      if (Array.isArray(excludedChunks) && excludedChunks.indexOf(chunkName) !== -1) { // chunks: Array
        return false;
      } else if (excludedChunks instanceof RegExp) { // chunks: RegExp
        return !excludedChunks.test(chunkName);
      } else if (typeof excludedChunks === 'function') { // chunks: Function
        return excludedChunks(chunkName);
      }
      // if (Array.isArray(excludedChunks) && excludedChunks.indexOf(chunkName) !== -1) {
      //   return false;
      // }
      // Add otherwise
      return true;
    });
  }

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

@zwlijun
Copy link
Author

zwlijun commented Dec 13, 2019

@jantimon
I commit pull request( #1320 ) for resolved this feature.
plz check it.

@bensampaio
Copy link

I was just now looking for a solution for this same problem. @zwlijun any updates on your PR?

@zwlijun
Copy link
Author

zwlijun commented Dec 17, 2019

I was just now looking for a solution for this same problem. @zwlijun any updates on your PR?

@bensampaio
yeah, I rewrite the filterChunks method and updated in PR.

@stale stale bot added the wontfix label Jun 14, 2020
Repository owner deleted a comment from stale bot Jun 15, 2020
@jantimon
Copy link
Owner

Can we update this to the current major version?

@stale stale bot closed this as completed Jul 3, 2020
@zwlijun
Copy link
Author

zwlijun commented Sep 13, 2020

@jantimon yeah, I hope so. thanks very much.

@vjpr
Copy link

vjpr commented Apr 16, 2022

Need this too for Module Federation to work. I need to exclude remoteEntry.js chunk, but its name is something like RemoteFoo. I want to be able to exclude all chunks starting with Remote.

Maybe allow matching on asset filename too.


EDIT: Seems like https://www.npmjs.com/package/html-webpack-skip-assets-plugin is the fix for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants