obvious-import-html
TypeScript icon, indicating that this package has built-in type declarations

0.0.1 • Public • Published

import-html

the middleware to load resources from html

Installation

npm install obvious-import-html

or

yarn add obvious-import-html

Usage

You can specify the html entry when you use the middleware

import { touchBus } from 'obvious-core'
import importHtml from 'obvious-import-html'

const [bus, isHost] = touchBus()

if (isHost) {
  bus.use(importHtml({
    'host-app': 'https://cdn.yours.com/host-app/index.html',
    'react-app': 'https://cdn.yours.com/react-app/index.html',
    'vue-app': 'https://cdn.yours.com/vue-app/index.html'
  }))
}

bus.activateApp('host-app')

Or you can use the loadHtml in the next middleware

import { touchBus } from 'obvious-core'
import importHtml from 'obvious-import-html'

const [bus, isHost] = touchBus()

if (isHost) {
  bus.use(importHtml()).use(async (ctx, next) => {
    const success = await ctx.loadHtml(`https://cdn.yours.com/${ctx.name}/index.html`)
    if (!success) {
      await next()
    }
  })
}

bus.activateApp('host-app')

License

obvious-import-html is MIT Licensed

Readme

Keywords

none

Package Sidebar

Install

npm i obvious-import-html

Weekly Downloads

0

Version

0.0.1

License

ISC

Unpacked Size

5.34 kB

Total Files

7

Last publish

Collaborators

  • runnan