Babel plugin for redirecting imports to a different location.
npm:
npm install babel-plugin-mock-imports --save-dev
yarn:
yarn add babel-plugin-mock-imports --dev
.babelrc:
{
"plugins": [
["mock-imports", {
"redirects": [
{
"pattern": ".(svg)$",
"location": "path/to/mocked/react/component"
},
{
"pattern": "^redux-form/es$",
"location": "redux-form"
}
]
}]
]
}
babel.config.js:
module.exports = {
plugins: [
['mock-imports', {
redirects: [
{
pattern: '.(svg)$',
location: 'path/to/mocked/react/component'
},
{
pattern: '^redux-form/es$',
location: 'redux-form'
}
]
}]
]
}
The pattern is evaluated using the RegExp
constructor.