Skip to content

Latest commit

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

rewrite-source-webpack-plugin

Webpack Plugin to rewrite the source before compilation. Files will be restored to their original state after compilation.

Why?

You may want to alter the source code before compilation. (E.g. if you have templated variables.)

Install

npm i -D rewrite-source-webpack-plugin

Usage

In 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"}),],

About

Webpack Plugin to rewrite the source before compilation

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages