1.2.2 • Published 7 months ago

energy-microfrontend v1.2.2

Weekly downloads
-
License
ISC
Repository
-
Last release
7 months ago

Schedules Microfrontend - Arisnova

This is a package that provides a schedules microfrontend to be embedded as iframe in vanilla JS. This package just needs an npm environment to install it.

Getting Started

Dependencies

Installing

SKIP THIS STEP IF PROJECT ALREADY HAS NPM ON IT.**

Setup an NPM environment.

cd root-folder
npm init

Install the microfrontend package in the project.

npm install schedules-microfrontend

Navigate to the file where you want to embed the microfrontend.

cd www/app/views/schedules

Edit corresponding file, for example: schedules.html and add an iframe with the package "index.html" in src.

# schedules.html
<iframe src="/node_modules/schedules-microfrontend/index.html" width="100%" height="100%" defer/>

Edit corresponding js file to declare needed dependencies. Is this case, it just need a valid socket instance.

# schedules.js
window.socket = "Socket instance"

Full working example

schedules.html

# schedules.html
<html>
<head>
<meta  charset="UTF-8"  />
    <title>test es6 modules</title>
    <script src="schedules.js"/>
</head>
<body>
	<h1>Example schedules Microfrontend</h1>
	<iframe src="/node_modules/schedules-microfrontend/index.html"  width="100%"  height="100%" defer/>
</body>
</html>

schedules.js

window.core = { socket:  "Socket instance" }

package.json

{
    "name": "vanilla-js-project",
    "version": "1.0.0",
    "description": "",
    "main": "index.js",
    "author": "",
    "license": "ISC",
    "dependencies": {
	    "schedules-microfrontend": "^0.0.2"
    }
}