Skip to content

Callback replace not working #60

@Durss

Description

@Durss

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 or loader-utils or ajv-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

  console.log("\nSEARCH :: ", search, replace);
  const newSource = source.replace(search, replace)

I also added a log on getOptionsArray.js :

  const rawOptions = getOptions(config)
  console.log(rawOptions);

And the "replace" field is simply missing from the log.
The search and flags 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 :

multiple: [
	   {
		search: 'hello',
		flags: 'gi',
		replace: 'test'
	   },
]

This does not :

multiple: [
	   {
		search: 'hello',
		flags: 'gi',
		replace: function(match, p1, offset, string) {
			return "test";
		},
	},
]

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions