webpack dynamic-replace-loader
Only replace within a single file, Please make sure that the content to be replaced is not accessed by other files
install
npm install --save-dev dynamic-replace-loadermodule.exports = {
module: {
rules: [
{
test: /\.js$/,
loader: 'dynamic-replace-loader',
},
],
},
};/* DYNAMIC-REPLACE _propA */
class User {
constructor() {
this._propA = 'private context'
}
printPropA() {
console.log(this._propA)
}
}The code output by load: ('_propA' was replaced by random characters 'MX')
/* DYNAMIC-REPLACE _propA */
class User {
constructor() {
this.MX = 'private context'
}
printPropA() {
console.log(this.MX)
}
}