Setup OPTION 2 - Using CDN
Using CDN For Lone Component and/or Microfrontend
In the CND mode, instead of the whole folder structure, only the app
folder and route.map.js
file are needed, also, we need to set the path where they'll be placeed by using the STILL_HOME
variable, follow the folder structure example as well as coding sample right after:
1. Folder Structure
First thing first, Still.js CDN based project are also named Lone component, and it's recommender for them to be create using still-cli
in addition to add to CDN in the page file itself (e.g. .html), as both the app/
folder and the route.map.js
file are needed even in this case, but the framework will be served from the CDN itself, hence, project structure can be as follow:
my-project-name
|
|_ microfronteds
| |_ still
| | |_ app
| | | |_ components
| | |_ config
| | | |_ route.map.js
| |_ another-mf-provider
|_ index.html
a. Creating Lone/CDN based project:
Creating the project inside the microfrontend/sill/
folder:
Project folder substructure considerations
In the above example structure, we have a folder name microfronted
, where we have the still
sub-folder, and, we also have component
folder inside the app root, nevertheless all 3 (microfronted, still and component) can be named as per the dev will.
2. Basic code sample
We can add our components in our HTML/App (React, Angular, etc.) by using<st-element>
tag instead of depending on the Still.js Application container to render the components, as it (Application container) is totally inexistent in this case.
Component creation
Although we don't have Still project structure in CDN mode, it's always recommended to use the still-cli to generate components, as this is the way the routes will be automatically added/managed in addition to the component generation.
Routing and route.map.js file
Despite Still App container is not available in the CND mode, navigation feature is still available, plus, it's needed for the framework to know how to locate the components, hence the route.map.js file.
3. Running the project in CDN mode
The proper way of running the project in the CDN mode is by having it from a web server, we'll use live-server
in this example, for that let's first install it:
Running the project from inside the project root folder ( my-project-name
)
Run result: