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

delete all empty chunk files without reason / 删除所有空文件 #273

Open
JiangWeixian opened this issue Sep 3, 2023 · 0 comments
Open

Comments

@JiangWeixian
Copy link
Owner

class DeleteEmptyAssetsPlugin {
  trash: string[];
  apply(compiler: Compiler) {
    compiler.hooks.thisCompilation.tap('DeleteEmptyAssetsPlugin', compilation => {
      compilation.hooks.afterOptimizeAssets.tap('DeleteEmptyAssetsPlugin', assets => {
        const emptyAssets = Object.keys(assets).filter(filename => {
          const asset = assets[filename];
          return asset.size() === 0;
        });
        if (emptyAssets.length !== 0) {
          console.log('Found empty chunks, try to delete it!');
        }
        emptyAssets.forEach(asset => delete compilation.assets[asset]);
      });
    });
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant