index.js 805 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. 'use strict'
  2. /**
  3. * https://www.npmjs.com/package/html-webpack-plugin
  4. * Async
  5. html-webpack-plugin-before-html-generation
  6. html-webpack-plugin-before-html-processing
  7. html-webpack-plugin-alter-asset-tags
  8. html-webpack-plugin-after-html-processing
  9. html-webpack-plugin-after-emit
  10. Sync:
  11. html-webpack-plugin-alter-chunks
  12. */
  13. /**
  14. *
  15. {
  16. events: {
  17. 'before-html-generation': function (data, cb) {
  18. cb(null, data)
  19. }
  20. }
  21. }
  22. */
  23. function Plugin(options) {
  24. this.events = options.events
  25. }
  26. Plugin.prototype.apply = function (compiler) {
  27. let _this = this
  28. compiler.plugin('compilation', function (compilation) {
  29. for (let i in _this.events) {
  30. compilation.plugin('html-webpack-plugin-' + i, _this.events[i]);
  31. }
  32. });
  33. };
  34. module.exports = Plugin;