UNPKG

@phoria/phoria-vue

Version:

Use Vue with Phoria Islands for dotnet.

53 lines (51 loc) 1.38 kB
import { createFilter as i, normalizePath as o } from "@rollup/pluginutils"; import d from "@vitejs/plugin-vue"; import f from "magic-string"; const h = "phoria-vue", u = { client: "client", ssr: "ssr" }, x = { include: ["**/*.vue"], exclude: "node_modules/**", cwd: process.cwd() }; function p(e) { const r = ["@phoria/phoria-vue/server"]; e.resolve ?? (e.resolve = {}), typeof e.resolve.external > "u" ? e.resolve.external = r : Array.isArray(e.resolve.external) && e.resolve.external.push(...r); } function w(e) { const r = { ...x, ...e }, l = i(r.include, r.exclude), s = o(r.cwd), m = new RegExp(`^${s}`, "i"); return { name: h, config: (t) => { var n, c; t.environments ?? (t.environments = {}), (n = t.environments)[c = u.ssr] ?? (n[c] = {}); }, configEnvironment(t, n) { t === u.ssr && p(n); }, transform(t, n) { if (!l(n)) return; const c = n.replace(m, ""), a = new f(t); a.append(` export const __phoriaComponentPath = "${c}";`); const v = a.generateMap({ source: n, file: `${n}.map`, includeContent: !0 }); return { code: a.toString(), map: v }; } }; } function P(e) { const r = (e == null ? void 0 : e.vue) !== !1 ? [d(e == null ? void 0 : e.vue)] : []; return r.push(w(e)), r; } export { P as phoriaVue };