Skip to content

teod/babel-plugin-mock-imports

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

49 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

Babel plugin for redirecting and mocking imports

Resources

License

Stars

Watchers

Forks

Packages

No packages published