Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/wrumsby/babel-plugin-resolve-bower-module
A Babel plugin to resolve ES6 imports that reference Bower modules.
https://github.com/wrumsby/babel-plugin-resolve-bower-module
Last synced: 6 days ago
JSON representation
A Babel plugin to resolve ES6 imports that reference Bower modules.
- Host: GitHub
- URL: https://github.com/wrumsby/babel-plugin-resolve-bower-module
- Owner: wrumsby
- Created: 2016-01-09T07:10:33.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2016-01-10T19:19:45.000Z (almost 9 years ago)
- Last Synced: 2024-08-10T09:17:18.723Z (3 months ago)
- Language: JavaScript
- Homepage:
- Size: 23.4 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# babel-plugin-resolve-bower-module
[![Build Status](https://travis-ci.org/wrumsby/babel-plugin-resolve-bower-module.svg?branch=master)](https://travis-ci.org/wrumsby/babel-plugin-resolve-bower-module)
A Babel plugin to resolve ES6 imports that reference Bower modules.
## Installation
```bash
npm install babel-plugin-resolve-bower-module --save-dev
```In your `.babelrc` file add the plugin to the `plugins` array:
```json
{
"plugins": [
"resolve-bower-module"
]
}
```## How it works
This plugin will look for `import` statements where the `module-name` matches a Bower module that is declared as a `dependency` or a `devDependency` of the project, e.g.
```js
import foo from 'foo';
```will be transformed to something like
```js
import foo from '../../bower_components/foo/src/index';
```## Options
If the plugin isn't resolving paths correctly or if your `bower.json` or `.bowerrc` aren't in `process.cwd()` you can pass `cwd` as an option to the plugin, e.g. in `.babelrc` specify
```json
{
"plugins": [
["resolve-bower-module", { "cwd": ".." }]
]
}
```