Skip to content

Allow plugins to import external assets #221

@gustavotrott

Description

@gustavotrott

Plugins should be able to import CSS files and other scripts without having to deal with complex path issues. Since the browser URL will be something like https://bbb.domain/html5client/ while the plugin might be hosted elsewhere, using relative paths for assets (such as images referenced in CSS) can be problematic.

To address this, the proposal is to allow plugins to declare additional assets in their manifest file. The asset URLs will be resolved relative to the manifest.js location, ensuring that resources inside CSS (images, fonts, etc.) are loaded correctly without the developer having to adjust paths manually.

Example manifest:

{
  "requiredSdkVersion": "<version>",
  "name": "MyPlugin",
  "javascriptEntrypointUrl": "MyPlugin.js",
  "javascriptEntrypointIntegrity": "sha384-Bwsz2rxm...",
  "assets": [
    {
      "type": "script",
      "url": "script.js",
      "integrity": "sha384-Bwsz2rxm..."
    },
    {
      "type": "module",
      "url": "main.js",
      "integrity": "sha384-Bwsz2rxm..."
    },
    {
      "type": "style",
      "url": "css/styles.css",
      "integrity": "sha384-Bwsz2rxm..."
    },
    {
      "type": "style",
      "url": "https://fonts.googleapis.com/css2?family=Roboto&display=swap"
    }
  ]
}

This would result in the client importing:

<script src="https://manifest-url/script.js" integrity="sha384-Bwsz2rxm..."></script>
<script src="https://manifest-url/main.js" type="module" integrity="sha384-Bwsz2rxm..."></script>
<link rel="stylesheet" href="https://manifest-url/css/styles.css" integrity="sha384-Bwsz2rxm...">
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Roboto&display=swap">

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions