module-mock-plugin
The plugin on enhanced-resolver for easy mock
Why use it?
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 reactnode_modules/ react/
src/__mock/react/index.js
{ // ... custom code}
Installation
npm install module-mock-plugin# or use yarn yarn add module-mock-plugin
Use in webpack
const ModuleMockPlugin = const webpackConfig = resolve: plugins:
Options
Extends the options from absolute-module-mapper-plugin
mockFilePath
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
include
The included paths for mapping
- Type:
Array<string|Function|RegExp>
- Default:
[/^((?!\/node_modules\/).)*$/]
exclude
The excluded paths for mapping
- Type:
Array<string|Function|RegExp>
- Default:
[]
Related
- absolute-module-mapper-plugin - The plugin on enhanced-resolver to map module path.
Contributing
- 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 :)
Authors
This library is written and maintained by imcuttle, moyuyc95@gmail.com.
License
MIT - imcuttle 🐟