babel-plugin-mock-imports

1.2.0 • Public • Published

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.

Readme

Keywords

none

Package Sidebar

Install

npm i babel-plugin-mock-imports

Weekly Downloads

53

Version

1.2.0

License

MIT

Unpacked Size

6.77 kB

Total Files

7

Last publish

Collaborators

  • teod