any-content-replace-loader
v0.0.5
Published
webpack loader: Replace content during compilation
Downloads
47
Maintainers
Readme
any-content-replace-loader
webpack loader: Replace content during compilation
example
replace abc with def by this loader
before:
// a.ts
console.log('a.ts: abc');
// b.ts
console.log('b.ts: abc');
after:
// a.ts
console.log('a.ts: def');
// b.ts
console.log('b.ts: def');
Demo
module: {
rules: [
{
test: /\.js$/,
use: [
{
loader: 'any-content-replace-loader',
options: {
search: /abc/gi,
replace: 'def',
},
},
],
exclude: /node_modules/,
},
],
},
if you use typescript:
module: {
rules: [
{
test: /\.ts$/,
use: [
'ts-loader',
{
loader: 'any-content-replace-loader',
options: {
search: /abc/gi,
replace: 'def',
},
},
],
exclude: /node_modules/,
},
],
},