https://github.com/ali322/content-replace-webpack-plugin
simple and efficient Webpack plugin that replace assets content when webpack emit files
https://github.com/ali322/content-replace-webpack-plugin
webpack
Last synced: over 1 year ago
JSON representation
simple and efficient Webpack plugin that replace assets content when webpack emit files
- Host: GitHub
- URL: https://github.com/ali322/content-replace-webpack-plugin
- Owner: ali322
- Created: 2018-01-11T08:47:15.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2023-01-04T01:05:07.000Z (over 3 years ago)
- Last Synced: 2025-02-28T16:01:05.296Z (over 1 year ago)
- Topics: webpack
- Language: JavaScript
- Size: 198 KB
- Stars: 8
- Watchers: 5
- Forks: 0
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
content-replace-webpack-plugin [](https://travis-ci.org/ali322/content-replace-webpack-plugin) [](https://badge.fury.io/js/content-replace-webpack-plugin)
===
[](https://nodei.co/npm/content-replace-webpack-plugin/)
simple and efficient plugin that replace assets content when webpack emit files
Install
===
```javascript
npm install content-replace-webpack-plugin --save--dev
```
Usage
===
add plugin in your webpack.config.js
```javascript
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](http://en.wikipedia.org/wiki/MIT_License)