Why use it.
Use it when image is separated from the server
.
Installation
npm install lesca-cdn-path --save
Usage
As a Node module: install in entry js.
import { install } from 'lesca-cdn-path';
install('https://cdn.hostname.com/files/');
setup mode
import { config } from 'lesca-cdn-path';
config.mode = 'localhost';
In the compnenet
import { path } from 'lesca-cdn-path';
const component = () => <img src={path(require('./img/image.jpg'))} />;
import { path } from 'lesca-cdn-path';
import Image from './img/image.jpg';
const component = () => <img src={path(Image)} />;
Development
Methods
method | description | return |
---|
.install(cdn-path:string) | set the base path was generated by the CDN | void |
.path(local-path:string) | localhost url path | cdn-path |
Properties
Properties | description | default |
---|
config.mode:sting | url loader mode(cdn ,localhost ) | 'cdn' |
Features