Skip to content

Commit

Permalink
Merge pull request #13 from yeojz/feature/refactor-code-structure
Browse files Browse the repository at this point in the history
refactor: code structure and update packages
  • Loading branch information
yeojz committed May 16, 2018
2 parents c08d081 + 3755fcd commit a4e1ab9
Show file tree
Hide file tree
Showing 12 changed files with 6,950 additions and 157 deletions.
14 changes: 6 additions & 8 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
{
"presets": [
"es2015"
],
"plugins": [
],
"env": {
"test": {
}
}
["env", {
"targets": {
"node": "6"
}
}]
]
}
18 changes: 8 additions & 10 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
{
"parser": "babel-eslint",
"env": {
"browser": true,
"commonjs": true,
"es6": true,
"node": true,
"mocha" : true
"mocha": true
},
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module",
"ecmaFeatures": {
"experimentalObjectRestSpread": true,
"jsx": true
}
"sourceType": "module"
},
"plugins": [
"prettier"
],
"extends": [
"eslint:recommended"
"eslint:recommended",
"plugin:prettier/recommended"
]
}
3 changes: 3 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"singleQuote": true
}
52 changes: 33 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
# babel-plugin-transform-assets-import-to-string

> Babel plugin that transforms image assets import and requires to urls / cdn
[![npm][npm-badge]][npm-link]
[![Build Status][circle-badge]][circle-link]

## Table of Contents

- [About](#about)
- [Installation](#installation)
- [Usage](#usage)
- [via babelrc](#via-babelrc)
- [via Node API](#via-node-api)
* [About](#about)
* [Installation](#installation)
* [Usage](#usage)
* [via babelrc](#via-babelrc)
* [via Node API](#via-node-api)

## About

Expand Down Expand Up @@ -47,36 +48,50 @@ $> npm install babel-plugin-transform-assets-import-to-string --save
## Usage

### via .babelrc

```json
{
"plugins": [["transform-assets-import-to-string", {
"baseDir": "/assets",
"baseUri": "http://your.cdn.address"
}]]
"plugins": [
[
"transform-assets-import-to-string",
{
"baseDir": "/assets",
"baseUri": "http://your.cdn.address"
}
]
]
}
```

### via Node API

```js
require("babel-core").transform("code", {
plugins: [["transform-assets-import-to-string", {
"baseDir": "/assets",
"baseUri": "http://your.cdn.address"
}]]
require('babel-core').transform('code', {
plugins: [
[
'transform-assets-import-to-string',
{
baseDir: '/assets',
baseUri: 'http://your.cdn.address'
}
]
]
});
```

By default, it will transform the following extensions: `.gif, .jpeg, .jpg, .png, .svg` if `extensions` option is not defined. To configure a custom list, just add the `extensions` array as an option.

__Note:__ leading `.` (dot) is required.
**Note:** leading `.` (dot) is required.

```json
{
"plugins": [
["transform-assets-import-to-string", {
"extensions": [".jpg", ".png"]
}]
[
"transform-assets-import-to-string",
{
"extensions": [".jpg", ".png"]
}
]
]
}
```
Expand All @@ -87,6 +102,5 @@ __Note:__ leading `.` (dot) is required.

[circle-badge]: https://img.shields.io/circleci/project/github/yeojz/babel-plugin-transform-assets-import-to-string/master.svg?style=flat-square
[circle-link]: https://circleci.com/gh/yeojz/babel-plugin-transform-assets-import-to-string

[npm-badge]: https://img.shields.io/npm/v/babel-plugin-transform-assets-import-to-string.svg?style=flat-square
[npm-link]: https://www.npmjs.com/package/babel-plugin-transform-assets-import-to-string
Loading

0 comments on commit a4e1ab9

Please sign in to comment.