Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bolasblack/module-mapper-webpack-plugin
A webpack plugin to replace module path
https://github.com/bolasblack/module-mapper-webpack-plugin
Last synced: 11 days ago
JSON representation
A webpack plugin to replace module path
- Host: GitHub
- URL: https://github.com/bolasblack/module-mapper-webpack-plugin
- Owner: bolasblack
- Created: 2019-08-11T14:47:32.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-10-29T00:17:32.000Z (3 months ago)
- Last Synced: 2024-11-10T03:36:30.807Z (2 months ago)
- Language: TypeScript
- Homepage:
- Size: 131 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# module-mapper-webpack-plugin [![Build Status](https://travis-ci.com/bolasblack/module-mapper-webpack-plugin.svg?branch=master)](https://travis-ci.com/bolasblack/module-mapper-webpack-plugin) [![Coverage Status](https://coveralls.io/repos/github/bolasblack/module-mapper-webpack-plugin/badge.svg?branch=master)](https://coveralls.io/github/bolasblack/module-mapper-webpack-plugin?branch=master)
## Usage
```bash
yarn add module-mapper-webpack-plugin -D
``````js
// webpack.config.tsimport { ModuleReplaceWebpackPlugin, replacePath } from 'module-mapper-webpack-plugin'
export default {
// ...
plugins: [
new ModuleReplaceWebpackPlugin({
async replacer(requestInfo) {
// modify requestInfo object directly
requestInfo.request = 'absolute path or path relative to issuer'// or return a new partial requestInfo
return {
request: 'absolute path or path relative to issuer',
}// for example:
if (
!/\/file\.overlay\b/.test(requestInfo.contextInfo.issuer) &&
/\/file\b/.test(requestInfo.request)
) {
return {
request: replacePath(
reqPath =>
path.resolve(
path.resolve(requestInfo.context, reqPath),
'../file.overlay.js',
),
d.request,
),
}
}
return requestInfo
},
} as ModuleReplaceWebpackPlugin.ConstructOptions)
],
}
```## Development
```bash
yarn build # build code
yarn watch # build and watch code
```