Skip to content

simple and efficient Webpack plugin that replace assets content when webpack emit files

Notifications You must be signed in to change notification settings

ali322/content-replace-webpack-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

content-replace-webpack-plugin Build Status npm version

NPM

simple and efficient plugin that replace assets content when webpack emit files

Install

npm install content-replace-webpack-plugin --save--dev

Usage

add plugin in your webpack.config.js

var ContentReplacePlugin = require('content-replace-webpack-plugin')

module.exports = {
    entry:{
        index:"./index.js"
    },
    module:{
        loaders:[
            ...
        ]
    },
    output:{
        path:'./dist',
        filename:'[name].min.js'
    },
    plugins:[
        new ContentReplacePlugin({
          external: ['path/to/other/file'], // other files which not in webpack assets
          chunks: ['index'],
          rules: {
            '.js': content => content.replace('/foo', '/bar')
          }
        })
    ]
}

Plugin Options

  • external: other files which not in webpack assets
  • rules: replace rules, accept object which key is file extname and value is replace function
  • chunks: only these chunks's files will be replaced, default value is all

License

MIT License

About

simple and efficient Webpack plugin that replace assets content when webpack emit files

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published