0.0.1 • Published 3 years ago

obvious-import-html v0.0.1

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

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

0.0.1

3 years ago