- 
                Notifications
    You must be signed in to change notification settings 
- Fork 2
          [mercury] Add the viteMercury plugin for Vite environments
          #646
        
          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
base: main
Are you sure you want to change the base?
Conversation
This will help us to avoid issues when the Mercury dependency is duplicated. Also, this help us to set this mapping inline in the HTML.
This plugin replaces the need for using the CLI in Vite environments.
Also, inline the base/base bundle by default and preload the base/icons bundle by default.
Also, fix default values for mercuryOptions
…li and vite-mercury-plugin packages Now, @genexus/mercury only contains the core of Mercury, and we have packages for bulding Mercury, using it through out a CLI, and a plugin to work with Vite. Breaking changes: - The default path for the fonts is now "/assets/fonts/" instead of "./assets/fonts/" - The default path for the icons is now "/assets/icons/" instead of "./assets/icons/"
| fileDir: fileMetadata.dir | ||
| .replace(MERCURY_DIST_RELATIVE_FOLDERS.DIST_BUNDLES_SCSS, "") | ||
| .replace("\\", "/") | 
Check failure
Code scanning / CodeQL
Incomplete string escaping or encoding High
          
            
              
                
              
            
            Show autofix suggestion
            Hide autofix suggestion
          
      Copilot Autofix
AI 12 days ago
To ensure all backslashes in fileMetadata.dir are replaced with forward slashes, the best way is to use a regular expression with the global flag: .replace(/\\/g, "/"). This replaces all occurrences, not just the first. Because the only change required is to the single line inside the BUNDLES.push call, we only need to update this line in packages/mercury-build/src/build/internal/transpile-bundle-and-create-mappings.ts. No additional imports or definitions are needed, since this is standard JavaScript regex usage.
- 
    
    
    Copy modified line R63 
| @@ -60,7 +60,7 @@ | ||
| BUNDLES.push({ | ||
| fileDir: fileMetadata.dir | ||
| .replace(MERCURY_DIST_RELATIVE_FOLDERS.DIST_BUNDLES_SCSS, "") | ||
| .replace("\\", "/") | ||
| .replace(/\\/g, "/") | ||
| }); | ||
|  | ||
| const transpiledBundle = transpileBundle( | 
        
          
                packages/mercury-build/src/build/internal/transpile-bundle-and-create-mappings.ts
              
                Fixed
          
            Show fixed
            Hide fixed
        
      We are no longer splitting the scss build with the assets copy, so we can centralize the Mercury build process
This plugin replaces the need for using the CLI in Vite environments.