string-replace-loader
string-replace-loader copied to clipboard
support callback function in options, make sure user can custom personal search rule.
module.exports = {
// ...
module: {
rules: [
{
test: /image\/*$/,
loader: 'string-replace-loader',
options: {
// search: '$', disable search
replace:(content)=> {
maps.forEach(item => {
content = content.replace(item, `${cdn}${item}`)
})
return content;
},
}
}
]
}
}
https://github.com/Va1/string-replace-loader/blob/54238608c65d6ce59d58371f4a7881c9d2807605/lib/replace.js#L18
hi!
this is already implemented, please refer to documentation – https://github.com/Va1/string-replace-loader#callback-replacement
@Va1 different with the document,no need to search option, just a callback function for user, get more possibility.