Plugin assets, external scripts and CSP overrides #4260
Merged
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.
This includes a refactoring of the way the
/javascript
and/css
endpoints work. These endpoints are changed to only return the custom javascript/css values provided in the configuration. Plugin-specific scripts and css files are now accessible via/plugin/{pluginID}/javascript
and/plugin/{pluginID}/css
respectively.Assets can now be configured in the plugin yml file using the
assets
field. Theassets
field maps URL prefixes to paths relative to the directory containing the plugin configuration file. The assets are available at the/plugin/{pluginID}/assets
URL path.For example:
This will map URLs to these locations:
/plugin/foo/assets/foo/file.txt
->{pluginDir}/bar/file.txt
/plugin/foo/assets/file.txt
->{pluginDir}/file.txt
/plugin/foo/assets/bar/file.txt
->{pluginDir}/bar/file.txt
(via theroot
entry)CSP policies
script-src
,style-src
andconnect-src
may now be added to via thecsp
field:The
css
andjavascript
fields now accept full external URLs. These URLs will be added tocsp.script-src
automatically. I tested thesceneCoverCropper
plugin with the following modification to the yml file:It still had errors unrelated to this change, but I confirmed that it loaded the css and js file correctly.