Overview

The CLI tool needs to be able to build Tailwind CSS taking into account the markup for all "online" components combined with any local component(s).

→ See: #3525571: [Meta] CLI tool for code components

Here is an overview of how JavaScript and CSS are compiled for code components (copied from docs/react-codebase/code-editor.md):

Code compilation for XB JS components

Proposed resolution

The command needs to replicate the Tailwind CSS part of the flow above using the following steps:

  1. Download the JS source of all code components into a local temporary directory, e.g., ~/.xb.
  2. Add the JS source of all selected components to the locally cached collection of all "online" components.
  3. Rebuild the class name candidates index maintained in the global xb_asset_library:

    1. Use extractClassNameCandidates() from balintbrews/tailwindcss-in-browser.
    2. Use code from ui/src/features/code-editor/utils/classNameCandidates.ts.
    3. See the XB app's implementation in ui/src/features/code-editor/hooks/useSourceCode.ts.
    4. Ensure we can use code from ui by moving cli into a workspace.
    5. Write the new class name candidate index to dist/index.js at the root of the local components directory.
  4. Using the updated class name candidate index, compile a list that contains all class name candidates for all components.
  5. Use buildCss() from balintbrews/tailwindcss-in-browser
  6. Write the generated CSS to dist/index.css at the root of the local components directory.
  7. Extend the upload command (#3525587: CLI command to upload code components) to run this compilation

    1. Upload the compiled CSS from dist/index.css to the global asset library's compiled CSS.
    2. Upload the class name candidate index from dist/index.js to the global asset library's class name candidate index.
CommentFileSizeAuthor
#4 xb-code-component-compilation.jpg449.27 KBbalintbrews
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

balintbrews created an issue. See original summary.

balintbrews’s picture

Issue summary: View changes
Status: Postponed » Active
balintbrews’s picture

Issue summary: View changes
balintbrews’s picture

Issue summary: View changes
StatusFileSize
new449.27 KB
hooroomoo’s picture

Assigned: Unassigned » hooroomoo

hooroomoo changed the visibility of the branch 3525592-cli-command-to to hidden.

hooroomoo’s picture

Assigned: hooroomoo » balintbrews
Status: Active » Needs review

balintbrews’s picture

Assigned: balintbrews » Unassigned
Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.