Skip to content
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

Allow stylesheet plugins #23

Closed
Yanrishatum opened this issue Aug 1, 2019 · 1 comment · Fixed by #24
Closed

Allow stylesheet plugins #23

Yanrishatum opened this issue Aug 1, 2019 · 1 comment · Fixed by #24

Comments

@Yanrishatum
Copy link
Contributor

Currently only javascript plugins can be loaded. However when implementing custom components and such, being able to inject css as well is preferable. Current obvious workaround is to load said css via entry point of plugin, but it's not ideal, since plugin have no clue where it is relative to IDE working directory (well, via Ide.inst.scripts clutch it can, but yeah - clutches).
What I propose:

  1. Replace loadScript with loadPlugin method that also capable of loading css files. (Keeping loadScript for backward compat, just in case)
  2. When presented with a string path, check file extension and load plugin as css stylsheet when extension is css.
  3. Allow passing a structure to plugins array:
struct PluginDescriptor = {
  @:optional var file:String;
  @:optional var type:String;
  @:optional var js:String;
  @:optional var css:String;
};

Where file and type can be used as path to specified plugin file and it's type. js and css are just file paths that would be loaded with their respective types.
As a result, plugins that are purely css (or js) can be loaded as:
["plugin.css", { css: "plugin.css" }, { file: "plugin.css", type: "css" }]
And when plugin utilizes both, it can be logically joined in a single object: [ { js: "plugin.js", css: "plugin.css" } ].
P.S. I already kinda implemented it, so I can just make a PR, but want to discuss it first. I'm doubting the need in file/type part for example.

@ncannasse
Copy link
Member

Yes, just autodetection based on file extension seems good enough for me.

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 a pull request may close this issue.

2 participants