BobManifestGenerator
BobManifestGenerator is a Webpack
plugin that helps you generate a manifest.json
file for your microservice, which can then be loaded via Bob.
Table of Contents
Prerequisites
In order to use BobManifestGenerator you need the following Prerequisites:
webpack
version 3
or highernode.js
version 8.12.0
or highernpm
version 6.4.1
or higher
How to use
In order to start using the plugin you should first install the package from npm
:
npm i -D @studyportals/bob-manifest-generator
After installing it you can import it to your webpack configuration file like so:
const BobManifestGenerator = require('@studyportals/bob-manifest-generator');
BobManifestGenerator provides 2 different plugins for you to use. Here you can see how to use both of them.
ManifestGenerator
ManifestGenerator takes care of building a manifest file for your microservice that is readable by Bob. You can use it like so:
plugins: [
new BobManifestGenerator.ManifestGenerator({
name: string,
html: string,
baseURL: string,
exclude: string[],
async: string[],
defer: string[]
})
]
Output
ManifestGenerator outputs a manifest file with the following structure:
{
"name": "Dummy Microservice",
"html": "https://bucket.prtl.co/index.html",
"assets": {
"js": [
{
"url": "https://bucket.prtl.co/dist/bundle.[hash].js",
"async": true
}
],
"css": [
{
"url": "https://bucket.prtl.co/dist/styles.[hash].css",
"defer": false
}
]
}
}
Options
When using the plugin, you can pass an options object to the constructor. This can include the following options:
Option | Description | Required |
---|
name | The name of your microservice. | yes |
html | The HTML that should be injected on the page the microservice is loaded in. | yes |
baseURL | The base URL for your microservice's assets. This will be prepended to the filenames. | no (default: '' ) |
exclude | An array of filenames to be excluded from the manifest. This can be just a filename or a filename including extension. When true is passed as a value, all assets will be excluded. | no (default: [] ) |
async | An array of JS filenames to be loaded async. This can be just a filename or a filename including extension. Keep in mind that only javascript assets may be loaded async. When true is passed as a value, all javascript assets will be loaded async. | no (default: [] ) |
defer | An array of CSS filenames to be lazy-loaded. This can be just a filename or a filename including extension. Keep in mind that only CSS assets may be lazy-loaded. When true is passed as a value, or when the value is omitted, all CSS assets will be lazy-loaded. | no (default: [] ) |
DLLReferencePlugin
DLLReferencePlugin can be used to create references to dependencies you want to use via DLL(Dynamic Library Linking). Bob will then take care of de-duplicating these dependencies when they are used by multiple microservices.
plugins: [
new BobManifestGenerator.DllReferencePlugin({
name: string,
manifest: object
})
]
Output
DLLReferencePlugin will add references to DLL dependencies to your manifest file like so:
{
"dllDependencies": [
{
"name": "[PACKAGE-NAME]-dll",
"fileName": "script.js",
"version": "1.0.0"
}
]
}
Options
When using the plugin, you can pass an options object to the constructor. This can include the following options:
Option | Description | Required |
---|
name | The name of the package without the @studyportals/ portion. | yes |
manifest | The manifest JSON that was generated by the DLL package you want to add as a dependency. | yes |