dynamic plugin paths (WIP)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<ui-mediapicker :config="config" :value="value" @input="$emit('input', $event)" :disabled="disabled" />
|
||||
<ui-mediapicker :config="{ limit }" :value="value" @input="$emit('input', $event)" :disabled="disabled" />
|
||||
</template>
|
||||
|
||||
|
||||
@@ -14,7 +14,15 @@
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
config: Object
|
||||
limit: {
|
||||
type: Number,
|
||||
default: 1
|
||||
}
|
||||
},
|
||||
|
||||
created()
|
||||
{
|
||||
console.info(this);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
+16
-28
@@ -2,31 +2,34 @@ const path = require('path');
|
||||
const fs = require('fs');
|
||||
const { createVuePlugin } = require('vite-plugin-vue2');
|
||||
|
||||
|
||||
let loadedPlugins = JSON.parse(process.env.ZERO_PLUGINS || "[]");
|
||||
let zeroPlugins = [];
|
||||
let _plugins = [
|
||||
{
|
||||
path: '../zero.Commerce/Plugin/vite.plugin.js',
|
||||
root: '../zero.Commerce/Plugin'
|
||||
},
|
||||
{
|
||||
path: '../../Laola/Laola.Backoffice/Plugin/vite.plugin.js',
|
||||
root: '../../Laola/Laola.Backoffice/Plugin'
|
||||
}
|
||||
];
|
||||
//let _plugins = [
|
||||
// {
|
||||
// path: '../zero.Commerce/Plugin/vite.plugin.js',
|
||||
// root: '../zero.Commerce/Plugin'
|
||||
// },
|
||||
// {
|
||||
// path: '../../Laola/Laola.Backoffice/Plugin/vite.plugin.js',
|
||||
// root: '../../Laola/Laola.Backoffice/Plugin'
|
||||
// }
|
||||
//];
|
||||
|
||||
let pluginFileContent = '';
|
||||
let pluginAliases = {};
|
||||
let pluginNames = [];
|
||||
let idx = 0;
|
||||
|
||||
_plugins.forEach(plugin =>
|
||||
loadedPlugins.forEach(pluginPath =>
|
||||
{
|
||||
const pluginConfig = require(plugin.path);
|
||||
const viteConfigPath = pluginPath + "/vite.plugin.js";
|
||||
const pluginConfig = require(viteConfigPath);
|
||||
zeroPlugins.push(pluginConfig());
|
||||
|
||||
const name = 'zeroPlugin' + idx;
|
||||
const alias = '/@zeroplugin' + (idx++) + '/';
|
||||
pluginAliases[alias] = path.resolve(__dirname, plugin.root);
|
||||
pluginAliases[alias] = path.resolve(__dirname, pluginPath);
|
||||
pluginNames.push(name);
|
||||
pluginFileContent += "import " + name + " from '" + alias + "plugin.js';\n";
|
||||
});
|
||||
@@ -43,21 +46,6 @@ fs.writeFile(path.resolve(__dirname, 'app/core/plugins.js'), pluginFileContent,
|
||||
//file written successfully
|
||||
})
|
||||
|
||||
//if (process.env.ZERO_PLUGINS)
|
||||
//{
|
||||
// let plugins = JSON.parse(process.env.ZERO_PLUGINS);
|
||||
|
||||
// plugins.forEach(plugin =>
|
||||
// {
|
||||
// const pluginConfig = require(plugin.path);
|
||||
|
||||
// if (pluginConfig != null)
|
||||
// {
|
||||
// zeroPlugins.push(pluginConfig());
|
||||
// }
|
||||
// });
|
||||
//}
|
||||
|
||||
const aliasResolver = {
|
||||
alias(id)
|
||||
{
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace Zero.Web.DevServer
|
||||
{
|
||||
public class PluginResolver
|
||||
{
|
||||
protected IEnumerable<IZeroPlugin> Plugins { get; set; }
|
||||
public IEnumerable<IZeroPlugin> Plugins { get; set; }
|
||||
|
||||
|
||||
public PluginResolver(IEnumerable<IZeroPlugin> plugins)
|
||||
|
||||
@@ -97,13 +97,15 @@ namespace Zero.Web.DevServer
|
||||
PidUtils.KillPort((ushort)port, true);
|
||||
|
||||
// get all plugins which need to be passed to vite
|
||||
var plugins = new List<dynamic>()
|
||||
List<string> plugins = new();
|
||||
|
||||
foreach (var plugin in pluginResolver.Plugins)
|
||||
{
|
||||
new
|
||||
if (!String.IsNullOrEmpty(plugin.Options.PluginPath))
|
||||
{
|
||||
path = Path.Combine(env.ContentRootPath, "../", "ViteZero.Plugin", "vite.plugin.js")
|
||||
plugins.Add(plugin.Options.PluginPath);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// create and run the vite script
|
||||
ProcessProxy process = new ProcessProxy(workingDirectory, "npm", options.Value.ForwardLog)
|
||||
|
||||
+13
-8
@@ -256,16 +256,21 @@ namespace zero.Web
|
||||
Dictionary<string, string> CreateTranslations()
|
||||
{
|
||||
var zeroTranslations = CreateTranslationsForFile("O:/zero/zero.Web/Resources/Localization/zero.en-us.json"); // TODO
|
||||
var commerceTranslations = CreateTranslationsForFile("O:/zero/zero.Commerce/Resources/Localization/zero.commerce.en-us.json");
|
||||
var debugTranslations = CreateTranslationsForFile("O:/Laola/Laola.Backoffice/Resources/laola.en-us.json"); // TODO move into project
|
||||
|
||||
foreach (var translation in commerceTranslations)
|
||||
foreach (IZeroPlugin plugin in Plugins)
|
||||
{
|
||||
zeroTranslations.Add(translation.Key, translation.Value);
|
||||
}
|
||||
foreach (var translation in debugTranslations)
|
||||
{
|
||||
zeroTranslations.Add(translation.Key, translation.Value);
|
||||
if (plugin.Options.LocalizationPaths.Count > 0)
|
||||
{
|
||||
foreach (string path in plugin.Options.LocalizationPaths)
|
||||
{
|
||||
Dictionary<string, string> translations = CreateTranslationsForFile(path);
|
||||
|
||||
foreach (var translation in translations)
|
||||
{
|
||||
zeroTranslations.Add(translation.Key, translation.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return zeroTranslations;
|
||||
|
||||
Reference in New Issue
Block a user