Skip to content

fix(windows): add Windows compatibility for env vars and glob patterns #1230

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

monatemedia
Copy link

Pull Request Title: Fix Windows Compatibility: Environment Variables & Glob Patterns


Pull Request Description:

Problem Statement

Opencast Studio does not run correctly on Windows due to two main issues:

  1. Environment Variables Not Windows-Compatible

    • The npm start and npm run build commands use Linux/macOS syntax for setting environment variables (VAR=value), which fails on Windows.
    • The error message:
      'COMMIT_SHA' is not recognized as an internal or external command, operable program or batch file.
  2. Glob Patterns Not Expanding on Windows

    • Webpack fails to resolve glob patterns (@(roboto-flex|vazirmatn)) on Windows, treating them as literal directory names instead of expanding them.
    • The error message:
      ERROR in unable to locate 'C:\Users\Lenovo\OneDrive\Coding Projects\opencast-studio\node_modules\@fontsource-variable\@(roboto-flex|vazirmatn)\index.css'

Solution

  • Issue 1: Add Windows-Compatible Start Command

    • Introduced a Windows-specific script (winstart) in package.json:
      "scripts": {
        "winstart": "set COMMIT_SHA=%COMMIT_SHA% && set BUILD_DATE=%BUILD_DATE% && webpack serve --open --mode=development"
      }
  • Issue 2: Replace Glob Patterns with Explicit Paths

    • Updated webpack.config.ts to use explicit file paths instead of glob patterns:
      new CopyPlugin({  
        patterns: [  
          { from: path.join(__dirname, "node_modules/@fontsource-variable/roboto-flex/index.css"), to: path.join(OUT_PATH, "font-roboto.css") },  
          { from: path.join(__dirname, "node_modules/@fontsource-variable/vazirmatn/index.css"), to: path.join(OUT_PATH, "font-vazirmatn.css") },  
          // Copy individual font files  
          { from: path.join(__dirname, "node_modules/@fontsource-variable/roboto-flex/files/roboto-flex-latin-wght-normal.woff2"), to: path.join(OUT_PATH, "fonts", "roboto-flex-latin-wght-normal.woff2") }  
        ]  
      })

Testing

Successfully tested across multiple environments:
✔ Windows Command Prompt
✔ Windows PowerShell
✔ GitBash on Windows
✔ Windows Subsystem for Linux 2 (WSL2)


Checklist (as per CONTRIBUTING.md)

✅ Pull request closes issue (not applicable).
✅ Clear and concise PR title and description.
✅ Relevant documentation updates included.
✅ Fix validated through manual testing on multiple Windows environments.
✅ Clean commit history.


Additional Notes

  • These changes ensure Opencast Studio can now build and run on Windows without issues.
  • Future contributors using Windows can use npm run winstart.
  • Open to feedback—let me know if any modifications are required. 🚀

@github-actions github-actions bot added the status:conflicts Conflicts with another pull request or issue label Apr 3, 2025
Copy link

github-actions bot commented Apr 3, 2025

This pull request has conflicts ☹
Please resolve those so we can review the pull request.
Thanks.

@github-actions github-actions bot removed the status:conflicts Conflicts with another pull request or issue label Apr 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant