I think I saw projects in development there too, anyway you right, it's better to add it there, when I will make stable version of my project.
I want to provide relative path to plugin directory in plugins code, instead of providing path relative to page specified in package.json
Currently I do this in plugins:
HIDE.loadJS("../plugins/boyan/jquery/bin/includes/js/jquery/jquery-2.0.3.min.js");
This makes plugin dependent on directory where it is located.
I think it's better to make it to understand path like this:
HIDE.loadJS("includes/js/jquery/jquery-2.0.3.min.js");
HIDE is a global var, which is defined in HIDE.js which is executed when index.html loads.
So for plugins located at folder "plugins", I can do something like this:
function loadJS(name, url)
{
var nameArray = name.split(.); //pass something like "boyan.jquery"
var path = require("path").join("plugins", nameArray[0], nameArray[1], "bin", url);
//loadJSByPath(path) something like that
}
But how to make it when plugin is located somewhere not in "plugins" directory...
Maybe core should remember path to each loaded plugin and then get it from some map:
HIDE.pathToPlugins["boyan.jquery"] = "path/to/plugin";
And then on loadJS from plugin do:
function loadJS(name, url)
{
var path = require("path").join(HIDE.pathToPlugins[name], "bin", url);
//loadJSByPath(path) something like that
}
If you guys think that there is exist better way to do this, please let me know. I feel like I'm doing it in not really good way.
воскресенье, 17 ноября 2013 г., 20:11:19 UTC+2 пользователь Jakub Szwacz написал: