Skip to content

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

Closed
@zwlijun

Description

@zwlijun

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions