Skip to content

csbun/babel-plugin-static

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

babel-plugin-static

babel plugin to replace static file path.

Build Status Coverage Status

Example

/* .babelrc */
{
  "plugins": [
    [ "static", {
      "assetsMapFile": "./config/webpack-assets.json",
      "assetsKey": "assets"
    }]
  ]
}
/* config/webpack-assets.json */
{
  "assets": {
    "./images/img.png": "http://cdn.example.com/path/to/img"
  }
}
// src/main.js
const img = require('../images/img.png');

will build to:

// dist/main.js (builded)
const img = require('../config/webpack-assets.json').assert['./images/img.png'];

Install

npm i babel-plugin-static -D

Usage

You can dump by using webpack-isomorphic-tools.

About

babel plugin to replace static file into url

Resources

License

Stars

Watchers

Forks

Packages

No packages published