Skip to content

Latest commit

 

History

History
61 lines (52 loc) · 1.08 KB

README.md

File metadata and controls

61 lines (52 loc) · 1.08 KB

Babel Plugin Mock Imports

npm version

Babel plugin for redirecting imports to a different location.

Quickstart

npm:

npm install babel-plugin-mock-imports --save-dev

yarn:

yarn add babel-plugin-mock-imports --dev

Usage

.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.