https://github.com/csbun/babel-plugin-static
babel plugin to replace static file into url
https://github.com/csbun/babel-plugin-static
Last synced: 11 months ago
JSON representation
babel plugin to replace static file into url
- Host: GitHub
- URL: https://github.com/csbun/babel-plugin-static
- Owner: csbun
- License: mit
- Created: 2016-08-19T10:18:02.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2019-11-27T11:33:41.000Z (about 6 years ago)
- Last Synced: 2025-01-07T23:22:49.859Z (about 1 year ago)
- Language: JavaScript
- Size: 289 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# babel-plugin-static
babel plugin to replace static file path.
[](https://travis-ci.org/csbun/babel-plugin-static)
[](https://coveralls.io/github/csbun/babel-plugin-static?branch=master)
## Example
```javascript
/* .babelrc */
{
"plugins": [
[ "static", {
"assetsMapFile": "./config/webpack-assets.json",
"assetsKey": "assets"
}]
]
}
```
```javascript
/* config/webpack-assets.json */
{
"assets": {
"./images/img.png": "http://cdn.example.com/path/to/img"
}
}
```
```javascript
// src/main.js
const img = require('../images/img.png');
```
will build to:
```javascript
// dist/main.js (builded)
const img = require('../config/webpack-assets.json').assert['./images/img.png'];
```
## Install
```sh
npm i babel-plugin-static -D
```
## Usage
You can dump by using [webpack-isomorphic-tools](https://github.com/halt-hammerzeit/webpack-isomorphic-tools).