Webpack Plugin to rewrite the source before compilation. Files will be restored to their original state after compilation.
You may want to alter the source code before compilation. (E.g. if you have templated variables.)
npm i -D rewrite-source-webpack-pluginIn your webpack.config.json, you can rewrite source files either by path or a regular expression:
plugins: [
...
newRewriteSourcePlugin([{test: /src\/App.js/,rewrite: (src)=>{returnsrc.replace(/{{foo}}/g,'A template variable');}},{path: './src/index.html',rewrite: (src)=>{returnsrc.replace(/{{title}}/g,'My page title');}},{path: './src/index.html',rewrite: (src)=>{returnsrc.replace(/{{description}}/g,'My page description');}},]),newHtmlWebPackPlugin({template: "./src/index.html",filename: "./index.html"}),],