README
Webpack
Replace loader forPerform replacements (plain and regular expression) in the contents loaded by the loader.
Install:
$ yarn add --dev string-replace-loader
With release of 2.0.0 the loader is expected to be used in Node v4+ environment. Support for Node v3 and lower was dropped, but you can install and use the loader version of 1.3.0 in older environments.
With release of 3.0.0 the loader is expected to be used with Webpack v5+. Support for Webpack v4 and lower was dropped, but you can install and use the loader version of 2.3.0 in older environments.
Usage:
Loader allows to perform replacements in a way String.prototype.replace() does (loader uses it internally).
It means that if you want to replace all occurrences, you should use RegExp-like string in options.search
with g
flag in options.flags
, etc.
Plain replacement:
Plain string replacement, no need to escape RegEx special characters.
In your webpack.config.js
:
module.exports = {
// ...
module: {
rules: [
{
test: /fileInWhichJQueryIsUndefined\.js$/,
loader: 'string-replace-loader',
options: {
search: '