You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to define Rule.useas a function instead of an array, so that I can gain access to the issuer string and use that information to generate my sprite names:
I tried hacking the SvgStorePlugin.js file to add support for the function syntax:
injectSpritesIntoRules(rules){for(construleofrules){const{oneOf: oneOfRules,rules: subRules,use: ruleUse}=rule;letloaders=ruleUse||[rule];// Check to see if ruleUse is a functionif(ruleUse&&{}.toString.call(ruleUse)==='[object Function]'){loaders=ruleUse();}
But sprite still ends up being undefined in loader.js:
functionloader(content){const{ addDependency, resource, resourcePath }=this;// Get callback because the SVG is going to be optimized and that is an async operationconstcallback=this.async();// Parse the loader query and apply the default values in case no values are providedconst{ iconName, publicPath, sprite, svgoOptions }=Object.assign({},DEFAULT_LOADER_OPTIONS,loaderUtils.getOptions(this));console.log(sprite);// undefined :(
I'd be willing to submit a pull request if I can figure this out, but I'm stuck. Any ideas?
The text was updated successfully, but these errors were encountered:
Hmm I guess this is a new feature... I don't think it was possible to pass a function to use when I came up with this idea. This was necessary to fix several complex issues but I don't think it will work for this case...
I would like to tell you how to go forward but I can't really come up with any idea right now. Although, I can tell you that what you are trying to do won't work. Unfortunately, I am quite busy at the moment so I don't think I'll have time to look into this any time soon 😞
Side note: You can detect functions in JS using ruleUse instanceof Function. No need for toString trickery :p
Thanks @bensampaio! I was able to satisfy the requirements of my project by doing the following, so I no longer need to use Rule.use as a function. It would still be a nice feature to have though.
I'm trying to define
Rule.use
as a function instead of an array, so that I can gain access to theissuer
string and use that information to generate my sprite names:Unfortunately, this results in the following error:
I tried hacking the
SvgStorePlugin.js
file to add support for the function syntax:But
sprite
still ends up beingundefined
inloader.js
:I'd be willing to submit a pull request if I can figure this out, but I'm stuck. Any ideas?
The text was updated successfully, but these errors were encountered: