-
Notifications
You must be signed in to change notification settings - Fork 14
feat: add paragon hosting configuration for dev and local environments (FC-87) #38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
brian-smith-tcril
merged 12 commits into
openedx:main
from
eduNEXT:afg/styles-hosting-setup
Sep 10, 2025
Merged
Changes from 6 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
92ed5c9
feat: add bundle minification build step for hosting
Ang-m4 f8ae77a
feat: add paragon static server and caddy configuration
Ang-m4 495a875
feat: add configuration for Paragon theme URLs in dev and local
Ang-m4 43e45ef
feat: add conditional logic for serving compiled themes
Ang-m4 cd9a9a0
feat: update static server from nginx to caddy for serving compiled t…
Ang-m4 8a5f42e
fix: update tutor dependency to remove upper version limit
Ang-m4 7ed1172
feat: update Paragon theme configuration and static server settings
Ang-m4 5f5f5fe
feat: add tutor-mfe service integration
Ang-m4 218879c
fix: integration test dependencies
Ang-m4 3a4dbd3
feat: add integration tests for hosted files
Ang-m4 f983f08
fix(test): update LMS_HOST variable for hosting tests
Ang-m4 da10f35
fix: update MFE_CONFIG to use 'brandOverride' for theme URLs
Ang-m4 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
plugins/tutor-contrib-paragon/tutorparagon/patches/caddyfile-lms
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| {% if PARAGON_SERVE_COMPILED_THEMES %} | ||
| # Tutor Paragon Caddyfile configuration for serving Paragon static files | ||
| handle_path /{{ PARAGON_STATIC_URL_PREFIX }}* { | ||
| @mincss { | ||
| # Match only minified CSS files | ||
| path_regexp mincss \.min\.css$ | ||
| } | ||
| handle @mincss { | ||
| # Proxy to the Paragon static files container | ||
| reverse_proxy paragon-statics:80 | ||
| } | ||
| } | ||
| {% endif %} |
11 changes: 11 additions & 0 deletions
11
plugins/tutor-contrib-paragon/tutorparagon/patches/local-docker-compose-services
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| {% if PARAGON_SERVE_COMPILED_THEMES %} | ||
| # Paragon Builder | ||
| paragon-statics: | ||
| image: {{ PARAGON_STATIC_SERVER_IMAGE }} | ||
| {% if not ENABLE_HTTPS %} | ||
| ports: | ||
| - "{{ PARAGON_STATIC_SERVER_PORT }}:80" | ||
| {% endif %} | ||
| volumes: | ||
| - "./../../{{ PARAGON_COMPILED_THEMES_PATH }}:/usr/share/caddy:ro" | ||
| {% endif %} |
23 changes: 23 additions & 0 deletions
23
plugins/tutor-contrib-paragon/tutorparagon/patches/openedx-lms-development-settings
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| {% if not PARAGON_ENABLED_THEMES %}{% set PARAGON_ENABLED_THEMES = ['light'] %}{% endif %} | ||
| {% set PROTOCOL = 'https' if ENABLE_HTTPS else 'http' %} | ||
| {% set BASE_URL = PROTOCOL ~ "://" ~ "localhost" ~ ":" ~ PARAGON_STATIC_SERVER_PORT ~ "/" %} | ||
|
Ang-m4 marked this conversation as resolved.
Outdated
|
||
|
|
||
| MFE_CONFIG["PARAGON_THEME_URLS"] = { | ||
| "core": { | ||
| "urls": { | ||
| "default": "{{ BASE_URL }}core/core.min.css" | ||
| }, | ||
| }, | ||
| "defaults": { | ||
| {% if 'light' in PARAGON_ENABLED_THEMES %}"light": "light",{% else %} | ||
| "light": "{{ PARAGON_ENABLED_THEMES | first }}",{% endif %} | ||
| {% if 'dark' in PARAGON_ENABLED_THEMES %}"dark": "dark"{% endif %} | ||
| }, | ||
| "variants": { | ||
| {% for theme in PARAGON_ENABLED_THEMES %}"{{ theme }}": { | ||
| "urls": { | ||
| "default": "{{ BASE_URL }}themes/{{ theme }}/{{ theme }}.min.css" | ||
| } | ||
| },{% endfor %} | ||
| } | ||
| } | ||
23 changes: 23 additions & 0 deletions
23
plugins/tutor-contrib-paragon/tutorparagon/patches/openedx-lms-production-settings
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| {% if not PARAGON_ENABLED_THEMES %}{% set PARAGON_ENABLED_THEMES = ['light'] %}{% endif %} | ||
| {% set PROTOCOL = 'https' if ENABLE_HTTPS else 'http' %} | ||
| {% set BASE_URL = PROTOCOL ~ "://" ~ LMS_HOST ~ "/" ~ PARAGON_STATIC_URL_PREFIX %} | ||
|
|
||
| MFE_CONFIG["PARAGON_THEME_URLS"] = { | ||
| "core": { | ||
| "urls": { | ||
| "default": "{{ BASE_URL }}core/core.min.css" | ||
| }, | ||
| }, | ||
| "defaults": { | ||
| {% if 'light' in PARAGON_ENABLED_THEMES %}"light": "light",{% else %} | ||
| "light": "{{ PARAGON_ENABLED_THEMES | first }}",{% endif %} | ||
| {% if 'dark' in PARAGON_ENABLED_THEMES %}"dark": "dark"{% endif %} | ||
| }, | ||
| "variants": { | ||
| {% for theme in PARAGON_ENABLED_THEMES %}"{{ theme }}": { | ||
| "urls": { | ||
| "default": "{{ BASE_URL }}themes/{{ theme }}/{{ theme }}.min.css" | ||
| } | ||
| },{% endfor %} | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -41,6 +41,33 @@ parse_args() { | |
| printf '%s\n' "$@" | ||
| } | ||
|
|
||
| build_css_bundle() { | ||
| # This function builds a CSS bundle using PostCSS. | ||
| # It takes the path to the index.css file as an argument. | ||
| # Usage: build_css_bundle <index_css_file> | ||
|
|
||
| local index_css_file="$1" | ||
|
|
||
| local bundle_directory=$(dirname "$index_css_file") | ||
| local bundle_name=$(basename "$bundle_directory") | ||
| local minified_output_file="$bundle_directory/${bundle_name}.min.css" | ||
|
|
||
| if npx postcss "$index_css_file" \ | ||
| --use postcss-import \ | ||
| --use postcss-custom-media \ | ||
| --use postcss-combine-duplicated-selectors \ | ||
| --use postcss-minify \ | ||
| --no-map \ | ||
| --output "$minified_output_file"; then | ||
|
|
||
| echo "Successfully created bundle: $bundle_name" | ||
| return 0 | ||
| else | ||
| echo "Failed to build CSS bundle: $bundle_name" >&2 | ||
| return 1 | ||
| fi | ||
| } | ||
|
Comment on lines
+44
to
+69
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not opposed to having this live here, but if we think postcss bundling paragon generated css will be a common thing then maybe it makes sense to build that functionality into the Paragon CLI. @PKulkoRaccoonGang thoughts? |
||
|
|
||
| set -- $(parse_args "$@") | ||
|
|
||
| # Executes the Paragon CLI to build themes. | ||
|
|
@@ -50,8 +77,14 @@ npx paragon build-tokens \ | |
| --build-dir "$TMP_BUILD_DIR" \ | ||
| "$@" | ||
|
|
||
| find "$TMP_BUILD_DIR" -type f -name 'index.css' | while read -r index; do | ||
| if [ -f "$index" ]; then | ||
| build_css_bundle "$index" | ||
| fi | ||
| done | ||
|
|
||
| # Moves the built themes to the final volume directory. | ||
| mkdir -p "$FINAL_BUILD_DIR" | ||
| rm -rf "$FINAL_BUILD_DIR"/* | ||
| cp -a "$TMP_BUILD_DIR/." "$FINAL_BUILD_DIR/" | ||
| chmod -R a+rw "$FINAL_BUILD_DIR" | ||
|
|
||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.