2.0.6 • Published 2 years ago

lesca-cdn-path v2.0.6

Weekly downloads
4
License
MIT
Repository
-
Last release
2 years ago

NPM React React React React React NPM

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';

// ? test at 'localhost'?;
config.mode = 'localhost'; // default is 'cdn'

In the compnenet

  • use require
import { path } from 'lesca-cdn-path';

const component = () => <img src={path(require('./img/image.jpg'))} />;
// http://localhost:8080/img/image.jpg => https://cdn.hostname.com/files/img/image.jpg
  • use import
import { path } from 'lesca-cdn-path';
import Image from './img/image.jpg';

const component = () => <img src={path(Image)} />;
// http://localhost:8080/img/image.jpg => https://cdn.hostname.com/files/img/image.jpg

Development

Methods

methoddescriptionreturn
.install(cdn-path:string)set the base path was generated by the CDNvoid
.path(local-path:string)localhost url pathcdn-path

Properties

Propertiesdescriptionoptionsdefault
config.mode:stingurl loader mode.cdn, localhost'cdn'

Features

  • maintain if necessary
2.0.3

2 years ago

2.0.2

2 years ago

2.0.5

2 years ago

2.0.4

2 years ago

2.0.6

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

1.0.1

3 years ago

1.0.0

3 years ago