0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-03-09 14:21:42 -05:00

Support development and production plugin runtime

This commit is contained in:
alonso.torres 2024-04-18 16:39:04 +02:00 committed by Andrey Antukh
parent 97c3abfd60
commit d7324b2e98
4 changed files with 14 additions and 23 deletions

View file

@ -23,25 +23,19 @@
{{/isDebug}}
<link rel="icon" href="images/favicon.png" />
<script type="importmap">
{"imports": {"plugins-runtime": "http://localhost:4200/index.mjs"}}
</script>
<script type="module" src="http://localhost:4200/index.mjs"></script>
<script>
window.penpotTranslations = JSON.parse({{& translations}});
window.penpotVersion = "%version%";
window.penpotBuildDate = "%buildDate%";
</script>
{{# manifest}}
<script>window.penpotWorkerURI="{{& worker}}"</script>
<script defer src="{{& config}}"></script>
<script defer src="{{& polyfills}}"></script>
{{/manifest}}
<script type="module" src="{{pluginRuntimeUri}}/index.mjs"></script>
<script>
window.penpotTranslations = JSON.parse({{& translations}});
window.penpotVersion = "%version%";
window.penpotBuildDate = "%buildDate%";
</script>
<!--cookie-consent-->
</head>
<body>
@ -49,17 +43,10 @@
{{> ../public/images/sprites/symbol/cursors.svg }}
<div id="app"></div>
<section id="modal"></section>
{{# manifest}}
{{# manifest}}
<script defer src="{{& shared}}"></script>
<script defer src="{{& main}}"></script>
<penpot-plugins />
{{/manifest}}
<script type="module">
import * as runtime from "plugins-runtime";
runtime.initialize(globalThis.app.plugins.api);
</script>
</body>
</html>

View file

@ -315,9 +315,12 @@ async function generateTemplates() {
"../public/images/sprites/symbol/cursors.svg": cursorsSprite,
};
const pluginRuntimeUri = (process.env.PENPOT_PLUGIN_DEV === "true") ? "http://localhost:4200" : "./plugins-runtime";
content = await renderTemplate("resources/templates/index.mustache", {
manifest: manifest,
translations: JSON.stringify(translations),
pluginRuntimeUri,
}, partials);
await fs.writeFile("./resources/public/index.html", content);
@ -401,6 +404,7 @@ export async function copyAssets() {
await syncDirs("resources/images/", "resources/public/images/");
await syncDirs("resources/fonts/", "resources/public/fonts/");
await syncDirs("resources/plugins-runtime/", "resources/public/plugins-runtime/");
const end = process.hrtime(start);
log.info("done: copy assets", `(${ppt(end)})`);

View file

@ -64,7 +64,7 @@ h.watch("resources/templates", null, async function (path) {
});
log.info("watch: assets (~)")
h.watch(["resources/images", "resources/fonts"], null, async function (path) {
h.watch(["resources/images", "resources/fonts", "resources/plugins-runtime"], null, async function (path) {
log.info("changed:", path);
await h.compileSvgSprites();
await h.copyAssets();

View file

@ -85,7 +85,7 @@ function run-devenv-tmux {
start-devenv
fi
docker exec -ti penpot-devenv-main sudo -EH -u penpot /home/start-tmux.sh
docker exec -ti penpot-devenv-main sudo -EH -u penpot PENPOT_PLUGIN_DEV=$PENPOT_PLUGIN_DEV /home/start-tmux.sh
}
function run-devenv-shell {