[WIP] Build process for frontendbase apps npm workspaces flavor (aka: the good one)#284
[WIP] Build process for frontendbase apps npm workspaces flavor (aka: the good one)#284holaontiveros wants to merge 34 commits into
Conversation
arbrandes
left a comment
There was a problem hiding this comment.
Great first stab, thank you!
I do have a lot of comments, though. Apologies in advance.
Also, it would be good to have an addition to the README explaining not only how to use this stuff, but how it works.
|
Took a quick look, most things appear to make sense at first glance, the one thing that stood out to me was:
Looking into the code and some comments from @arbrandes it started to make sense (it's so we can handle what https://github.com/openedx/frontend-template-site/blob/main/src/site.scss does). So this really becomes more of a |
|
@brian-smith-tcril I'm guessing because we don't import the css at the Now why we do it like that and not somewhere else may be related with a decision on how we are using webpack maybe? @arbrandes |
The simple answer: app SCSS must be imported somewhere by the consuming application (in our case, the site) because apps are not distributed with pre-compiled CSS. If y'all can think of a better way to handle this, I'm all ears! |
|
Ah, turns out we actually documented this in ADR 8, way-back-when. It's a webpack quirk. |
… into frontend-base-c-side
|
@holaontiveros, thanks a lot for this! I squashed this PR into a single commit in a new upstream frontend-base branch (and associated PR) we can use for coordination. While I'm closing this, consider it merged! :) Note, however, that I already made significant changes to the mechanism in order to simplify it and bring it more in line with how tutor (and tutor-mfe) usually do things (more sources of truth inside templates, instead of configuration variables). I also took a first stab at adding dev mount support (for sites only, so far - still working on apps). |
Basic details
This is the first step for the build process of the frontend apps, what it does:
FRONTEND_APPS) that will be used to know which apps should be frontendbaseFRONTEND_SITES) to know which "sites" are going to be build, by default we have a local one but operators are going to be able to override the default one or add extra onesiter_pathswhich returns the paths that should be used in the Caddyfile, taking in account that they could be either from the old MFEs or from a new frontendapp that didn't have MFE beforeis_frontend_appwhich checks if the app is "enabled" as a frontend app so Caddy does some path magicpackage.jsonandsite.scsssite.config.x.tsxPending things
Maybe multi-stage sites part (?)General cleanup and better semantic namingsentryPoint configs for appsconfigs for sitepluginSlots equivalentpatch locationsHow to add a frontendapp
In order to mark something as a frontendbase app you need a plugin that looks like:
and if you need some of those to be manually build and installed in the frontend-site:
When no
repositoryandversionare specified nothing will be added to thepackages/folder for that frontend-app so npm will try to fetch them from the registryAny app that it's on this list will be considered a fronend-app so when Caddy shows the content for it, it will show the one on frontend-site instead of the normal app.
By default there's going to be a frontend-site that it's build from files in the tutor-mfe plugin (everything under
tutormfe/templates/mfe/build/mfe/frontend-site)if the operator wants to add a new site or substitute the default one it can be done like:
The structure is the same as adding an MFE the only thing to take in account is that if you want to add a new site with a different name than default you also need to specify which frontend apps will live there so Caddy knows that it should serve those files
In case that further customization is required for the a frontensite the full config looks like:
Config values reference
siteIdinside site.config.xx.tsx'tutor-frontend-site'siteNameinside site.config.xx.tsx'Frontend site'accessTokenCookieNameinside site.config.xx.tsx'edx-jwt-cookie-header-payload'http://apps.local.openedx.io:8080/(root route)''the default would fail and throw a 404 so a role needs to always be defined and pointing to the proper place'tutor-frontend-site''tutor-frontend-site'[]Front end slots
Given the current architecture of a frontendbase the slots part has been dramatically simplified and made more powerful, so for complex slot situations you can always create an app based on the template-site and just export the slots you require, but if you need a single file plugin / config for a slot then we get the new
@FRONTEND_SLOTSThe usage will be similar to the current
@PLUGIN_SLOTSbut way more simplified, ex:This is a widget that it's configured to add be added at the
org.openedx.frontend.slot.header.primaryLinks.v1'ID which exists in the header and Adds a new link next to whichever is already thereThe main difference is that we no longer need the app name, just the slotID (and currently it's not used...) and the slot config, any slot configured here will be configured in a mini-app which just makes the slots available for the build
slots.tsxNew patches
Some new patches were introduced to cover previous available functionality that may be used to extend frontend app functionality