项目原始demo,不改动
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
此仓库已存档。您可以查看文件和克隆,但不能推送或创建工单/合并请求。

NamedChunksPlugin.js 653 B

4 年前
123456789101112131415161718192021222324252627282930
  1. /*
  2. MIT License http://www.opensource.org/licenses/mit-license.php
  3. Author Tobias Koppers @sokra
  4. */
  5. "use strict";
  6. class NamedChunksPlugin {
  7. static defaultNameResolver(chunk) {
  8. return chunk.name || null;
  9. }
  10. constructor(nameResolver) {
  11. this.nameResolver = nameResolver || NamedChunksPlugin.defaultNameResolver;
  12. }
  13. apply(compiler) {
  14. compiler.plugin("compilation", (compilation) => {
  15. compilation.plugin("before-chunk-ids", (chunks) => {
  16. chunks.forEach((chunk) => {
  17. if(chunk.id === null) {
  18. chunk.id = this.nameResolver(chunk);
  19. }
  20. });
  21. });
  22. });
  23. }
  24. }
  25. module.exports = NamedChunksPlugin;