SupportExtractTextPlugin.js 872 B

12345678910111213141516171819202122232425262728293031323334
  1. const path = require('path');
  2. let extractTextNS;
  3. let extractTextNS2;
  4. try {
  5. extractTextNS = path.dirname(require.resolve('extract-text-webpack-plugin'));
  6. } catch (_) {}
  7. const pluginCompat = require('./util/plugin-compat');
  8. class SupportExtractTextPlugin {
  9. apply(compiler) {
  10. pluginCompat.tap(
  11. compiler,
  12. '_hardSourceAfterFreezeModule',
  13. 'SupportExtractTextPlugin',
  14. (frozen, module, extra) => {
  15. // Ignore the modules that kick off child compilers in extract text.
  16. // These modules must always be built so the child compilers run so
  17. // that assets get built.
  18. if (
  19. module[extractTextNS] ||
  20. (!module.factoryMeta && module.meta && module.meta[extractTextNS])
  21. ) {
  22. return null;
  23. }
  24. return frozen;
  25. },
  26. );
  27. }
  28. }
  29. module.exports = SupportExtractTextPlugin;