NamedModulesPlugin.js 596B

12345678910111213141516171819202122232425262728
  1. /*
  2. MIT License http://www.opensource.org/licenses/mit-license.php
  3. Author Tobias Koppers @sokra
  4. */
  5. "use strict";
  6. class NamedModulesPlugin {
  7. constructor(options) {
  8. this.options = options || {};
  9. }
  10. apply(compiler) {
  11. compiler.plugin("compilation", (compilation) => {
  12. compilation.plugin("before-module-ids", (modules) => {
  13. modules.forEach((module) => {
  14. if(module.id === null && module.libIdent) {
  15. module.id = module.libIdent({
  16. context: this.options.context || compiler.options.context
  17. });
  18. }
  19. });
  20. });
  21. });
  22. }
  23. }
  24. module.exports = NamedModulesPlugin;