-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Callback replace not working #60
Comments
Some more info. I tried to copy/paste the plugin to my local folder, removed all the external dependencies, and i still have the problem. If i log the raw options, any Function typed param get stripped out the object. The way to use a plugin with Vue env is a bit special (not sure it's specific to Vue actually) as it looks like this : chainWebpack: (config) => {
config.module.rule()
.test(/\.ts$/)
.use()
.loader("./local-string-replace")
.options({
multiple: [
{
search: 'hello',
flags: 'gi',
testRep: function(match, p1, offset, string) {
return "test?"
},
replace: function(match, p1, offset, string) {
return "morning!";
},
},
]
}
);
}, Maybe there's some sanitazing somewhere that cleansup params to remove potentially sensitive stuff like function calls... |
I`m experiencing the same issue. @Durss did you find a solution? |
Nope i just created something from scratch more or less equivalent to this plugin that answered my needs :/ |
hi. there' a test-case written for the callback replacement and it works. can you check if that's approximately how you're approaching callback replacement as well? thanks https://github.com/Va1/string-replace-loader/blob/master/test/index.test.js#L135 |
Hello !
I'm having lots of troubles having the callback replace working.
I put logs in many places and i'm tempted to say it may come either from
schema-utils
orloader-utils
orajv-keyword
modules but i'm very new to webpack plugins so i can't tell for sure.If i add this log in replace.js
I also added a log on getOptionsArray.js :
And the "replace" field is simply missing from the log.
The
search
andflags
keys are here.If the replacement is a string the logs show the replacement properly, if the replacement is a fucntion, i get "null" everytime, except once sometimes at the end of the build.
This works :
This does not :
Sometimes when i close the project (vscode), kill the node processes, and try to build again, the callback is passed properly everytime. But this happens very very randomly. It seems like there's also a compile cache somewhere that blocks the plugin's call or something.
I never put my hands inside webpack so i may be missing a thing.
Any idea what could be the reason of this?
The text was updated successfully, but these errors were encountered: