项目原始demo,不改动
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
 
 
 
 

31 lines
653 B

  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;