Skip to content

ragu-framework/ragu-simple-adapter

Repository files navigation

Ragu

Ragu Simple Adapter

Testing License: MIT npm version PRs Welcome

A simple adapter for Ragu Server - A micro-frontend framework.

Installation

yarn add webpack ragu-cli ragu-simple-adapter

Exposing a Component

Create a file that renders your component:

// my-mfe.js
module.exports = () => ({
  html: 'Hello, World'
})

After, start the ragu server specifying your adapter:

yarn ragu-cli dev --file my-mfe.js --adapter simple

Open your browser at http://localhost:3100/preview to check your micro-frontend live!

That's all!

Build to production

yarn ragu-cli static --file my-mfe.js --baseurl https://mycdnhost/mymfe --output production --adapter simple

It will create a directory called production with a file called index.json.

Using your component

<head>
  <script src="https://cdn.jsdelivr.net/npm/ragu-dom@latest/ragu-dom.js" crossorigin="anonymous"></script>
  <script>RaguDOM.registerRaguComponent();</script>
</head>

<body>
  <ragu-framework src="https://mycdnhost/mymfe/index.json"></ragu-framework>
</body>

Check The docs for More: https://ragu-framework.github.io/#!/ragu-simple-adapter