AppendPlugin.js 676B

1234567891011121314151617181920212223
  1. /*
  2. MIT License http://www.opensource.org/licenses/mit-license.php
  3. Author Tobias Koppers @sokra
  4. */
  5. function AppendPlugin(source, appending, target) {
  6. this.source = source;
  7. this.appending = appending;
  8. this.target = target;
  9. }
  10. module.exports = AppendPlugin;
  11. AppendPlugin.prototype.apply = function(resolver) {
  12. var target = this.target;
  13. var appending = this.appending;
  14. resolver.plugin(this.source, function(request, callback) {
  15. var obj = Object.assign({}, request, {
  16. path: request.path + appending,
  17. relativePath: request.relativePath && (request.relativePath + appending)
  18. });
  19. resolver.doResolve(target, obj, appending, callback);
  20. });
  21. };