The plugin on enhanced-resolver for easy mock
One day your project (using React) needs to change the browser's default hovering title behavior as a whole.
This is a lot of work, so the implementation of small modifications is mock react module, so that the place where react is imported in the project points to our custom react module.
src/
__mock/
react/ # custom react
node_modules/
react/
src/__mock/react/index.js
import React from 'react'
export * from 'react'
export function createElement(type, props, children) {
// ... custom code
}
npm install module-mock-plugin
# or use yarn
yarn add module-mock-plugin
const ModuleMockPlugin = require('module-mock-plugin')
const webpackConfig = {
resolve: {
plugins: [new ModuleMockPlugin()]
}
}
Extends the options from absolute-module-mapper-plugin
The path of mock directory, it could be inferred as the closest file from origin file, or assigning special file path by absolute path.
- Type:
string
- Default:
__mocks
The included paths for mapping
- Type:
Array<string|Function|RegExp>
- Default:
[/^((?!\/node_modules\/).)*$/]
The excluded paths for mapping
- Type:
Array<string|Function|RegExp>
- Default:
[]
- absolute-module-mapper-plugin - The plugin on enhanced-resolver to map module path.
- Fork it!
- Create your new branch:
git checkout -b feature-new
orgit checkout -b fix-which-bug
- Start your magic work now
- Make sure npm test passes
- Commit your changes:
git commit -am 'feat: some description (close #123)'
orgit commit -am 'fix: some description (fix #123)'
- Push to the branch:
git push
- Submit a pull request :)
This library is written and maintained by imcuttle, moyuyc95@gmail.com.
MIT - imcuttle 🐟