vue-wswg-editor 0.0.14 → 0.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/types/vite-plugin.d.ts +6 -0
- package/dist/vite-plugin.js +35 -32
- package/package.json +1 -2
- package/src/vite-plugin.ts +25 -5
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
import type { Plugin } from "vite";
|
|
2
|
+
export type SkipableModule = "fields" | "thumbnails";
|
|
2
3
|
export interface VueWswgEditorPluginOptions {
|
|
3
4
|
/**
|
|
4
5
|
* Root directory in the host project.
|
|
5
6
|
* Example: "@/features/homepage"
|
|
6
7
|
*/
|
|
7
8
|
rootDir: string;
|
|
9
|
+
/**
|
|
10
|
+
* Array of module types to skip loading.
|
|
11
|
+
* Skipped modules will return an empty object, preventing Vite from scanning those files.
|
|
12
|
+
*/
|
|
13
|
+
skipModules?: SkipableModule[];
|
|
8
14
|
}
|
|
9
15
|
export declare function vueWswgEditorPlugin(options: VueWswgEditorPluginOptions): Plugin;
|
package/dist/vite-plugin.js
CHANGED
|
@@ -1,21 +1,24 @@
|
|
|
1
|
-
function a(
|
|
2
|
-
const
|
|
1
|
+
function a(o) {
|
|
2
|
+
const s = {
|
|
3
3
|
blocks: "\0vue-wswg-editor:blocks",
|
|
4
4
|
fields: "\0vue-wswg-editor:fields",
|
|
5
5
|
layouts: "\0vue-wswg-editor:layouts",
|
|
6
6
|
thumbnails: "\0vue-wswg-editor:thumbnails",
|
|
7
7
|
themes: "\0vue-wswg-editor:themes"
|
|
8
|
+
}, l = (e) => {
|
|
9
|
+
var t;
|
|
10
|
+
return ((t = o.skipModules) == null ? void 0 : t.includes(e)) ?? !1;
|
|
8
11
|
};
|
|
9
12
|
return {
|
|
10
13
|
name: "vue-wswg-editor-glob-plugin",
|
|
11
14
|
enforce: "pre",
|
|
12
15
|
// Run before other plugins to ensure import.meta.glob is processed correctly
|
|
13
|
-
config(
|
|
14
|
-
var
|
|
15
|
-
const
|
|
16
|
+
config(e) {
|
|
17
|
+
var n;
|
|
18
|
+
const t = e.optimizeDeps || {}, r = t.exclude;
|
|
16
19
|
let u;
|
|
17
|
-
Array.isArray(
|
|
18
|
-
const
|
|
20
|
+
Array.isArray(r) ? u = [...r] : typeof r == "string" ? u = [r] : u = [];
|
|
21
|
+
const d = [
|
|
19
22
|
"vue-wswg-editor",
|
|
20
23
|
"vue-wswg-editor:layouts",
|
|
21
24
|
"vue-wswg-editor:blocks",
|
|
@@ -23,16 +26,16 @@ function a(r) {
|
|
|
23
26
|
"vue-wswg-editor:thumbnails",
|
|
24
27
|
"vue-wswg-editor:themes"
|
|
25
28
|
];
|
|
26
|
-
for (const i of
|
|
29
|
+
for (const i of d)
|
|
27
30
|
u.includes(i) || u.push(i);
|
|
28
31
|
return {
|
|
29
32
|
optimizeDeps: {
|
|
30
|
-
...
|
|
33
|
+
...t,
|
|
31
34
|
exclude: u,
|
|
32
35
|
esbuildOptions: {
|
|
33
|
-
...
|
|
36
|
+
...t.esbuildOptions,
|
|
34
37
|
plugins: [
|
|
35
|
-
...((
|
|
38
|
+
...((n = t.esbuildOptions) == null ? void 0 : n.plugins) || [],
|
|
36
39
|
{
|
|
37
40
|
name: "vue-wswg-editor-virtual-modules",
|
|
38
41
|
setup(i) {
|
|
@@ -44,33 +47,33 @@ function a(r) {
|
|
|
44
47
|
}
|
|
45
48
|
};
|
|
46
49
|
},
|
|
47
|
-
resolveId(
|
|
48
|
-
if (
|
|
49
|
-
const
|
|
50
|
-
if (
|
|
51
|
-
return
|
|
50
|
+
resolveId(e) {
|
|
51
|
+
if (e.startsWith("vue-wswg-editor:")) {
|
|
52
|
+
const r = e.replace("vue-wswg-editor:", "");
|
|
53
|
+
if (r in s)
|
|
54
|
+
return s[r];
|
|
52
55
|
}
|
|
53
|
-
if (Object.values(
|
|
54
|
-
return
|
|
56
|
+
if (Object.values(s).includes(e))
|
|
57
|
+
return e;
|
|
55
58
|
},
|
|
56
|
-
load(
|
|
57
|
-
switch (
|
|
58
|
-
case
|
|
59
|
-
return `export const modules = import.meta.glob("${
|
|
60
|
-
case
|
|
61
|
-
return `export const modules = import.meta.glob("${
|
|
62
|
-
case
|
|
63
|
-
return `export const modules = import.meta.glob("${
|
|
64
|
-
case
|
|
65
|
-
return `export const modules = import.meta.glob(["${
|
|
66
|
-
case
|
|
67
|
-
return `export const modules = import.meta.glob("${
|
|
59
|
+
load(e) {
|
|
60
|
+
switch (e) {
|
|
61
|
+
case s.layouts:
|
|
62
|
+
return l("layouts") ? "export const modules = {};" : `export const modules = import.meta.glob("${o.rootDir}/*/layout/**/*.vue", { eager: true });`;
|
|
63
|
+
case s.blocks:
|
|
64
|
+
return l("blocks") ? "export const modules = {};" : `export const modules = import.meta.glob("${o.rootDir}/*/blocks/**/*.vue", { eager: true });`;
|
|
65
|
+
case s.fields:
|
|
66
|
+
return l("fields") ? "export const modules = {};" : `export const modules = import.meta.glob("${o.rootDir}/*/blocks/**/fields.ts", { eager: false });`;
|
|
67
|
+
case s.thumbnails:
|
|
68
|
+
return l("thumbnails") ? "export const modules = {};" : `export const modules = import.meta.glob(["${o.rootDir}/*/blocks/**/thumbnail.png", "${o.rootDir}/*/thumbnail.jpg", "${o.rootDir}/*/thumbnail.png"], { eager: true });`;
|
|
69
|
+
case s.themes:
|
|
70
|
+
return l("themes") ? "export const modules = {};" : `export const modules = import.meta.glob("${o.rootDir}/**/theme.config.js", { eager: true });`;
|
|
68
71
|
default:
|
|
69
72
|
return;
|
|
70
73
|
}
|
|
71
74
|
},
|
|
72
|
-
transform(
|
|
73
|
-
if (Object.values(
|
|
75
|
+
transform(e, t) {
|
|
76
|
+
if (Object.values(s).includes(t))
|
|
74
77
|
return null;
|
|
75
78
|
}
|
|
76
79
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vue-wswg-editor",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.15",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/vue-wswg-editor.es.js",
|
|
6
6
|
"module": "./dist/vue-wswg-editor.es.js",
|
|
@@ -50,7 +50,6 @@
|
|
|
50
50
|
"format-fix": "npm run tscheck && npm run prettier-fix && npm run lint-fix && npm run stylelint-fix"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@headlessui/vue": "^1.7.23",
|
|
54
53
|
"@heroicons/vue": "^2.2.0",
|
|
55
54
|
"@vueuse/core": "^14.0.0",
|
|
56
55
|
"sass": "^1.89.2",
|
package/src/vite-plugin.ts
CHANGED
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
// my-lib/src/plugin.ts
|
|
2
2
|
import type { Plugin } from "vite";
|
|
3
3
|
|
|
4
|
+
export type SkipableModule = "fields" | "thumbnails";
|
|
5
|
+
|
|
4
6
|
export interface VueWswgEditorPluginOptions {
|
|
5
7
|
/**
|
|
6
8
|
* Root directory in the host project.
|
|
7
9
|
* Example: "@/features/homepage"
|
|
8
10
|
*/
|
|
9
11
|
rootDir: string;
|
|
12
|
+
/**
|
|
13
|
+
* Array of module types to skip loading.
|
|
14
|
+
* Skipped modules will return an empty object, preventing Vite from scanning those files.
|
|
15
|
+
*/
|
|
16
|
+
skipModules?: SkipableModule[];
|
|
10
17
|
}
|
|
11
18
|
|
|
12
19
|
export function vueWswgEditorPlugin(options: VueWswgEditorPluginOptions): Plugin {
|
|
@@ -18,6 +25,9 @@ export function vueWswgEditorPlugin(options: VueWswgEditorPluginOptions): Plugin
|
|
|
18
25
|
themes: "\0vue-wswg-editor:themes",
|
|
19
26
|
};
|
|
20
27
|
|
|
28
|
+
const shouldSkip = (module: keyof typeof virtualModules) =>
|
|
29
|
+
options.skipModules?.includes(module as SkipableModule) ?? false;
|
|
30
|
+
|
|
21
31
|
return {
|
|
22
32
|
name: "vue-wswg-editor-glob-plugin",
|
|
23
33
|
enforce: "pre", // Run before other plugins to ensure import.meta.glob is processed correctly
|
|
@@ -92,15 +102,25 @@ export function vueWswgEditorPlugin(options: VueWswgEditorPluginOptions): Plugin
|
|
|
92
102
|
// Using a more explicit format to ensure Vite processes it correctly
|
|
93
103
|
switch (id) {
|
|
94
104
|
case virtualModules.layouts:
|
|
95
|
-
return
|
|
105
|
+
return shouldSkip("layouts")
|
|
106
|
+
? `export const modules = {};`
|
|
107
|
+
: `export const modules = import.meta.glob("${options.rootDir}/*/layout/**/*.vue", { eager: true });`;
|
|
96
108
|
case virtualModules.blocks:
|
|
97
|
-
return
|
|
109
|
+
return shouldSkip("blocks")
|
|
110
|
+
? `export const modules = {};`
|
|
111
|
+
: `export const modules = import.meta.glob("${options.rootDir}/*/blocks/**/*.vue", { eager: true });`;
|
|
98
112
|
case virtualModules.fields:
|
|
99
|
-
return
|
|
113
|
+
return shouldSkip("fields")
|
|
114
|
+
? `export const modules = {};`
|
|
115
|
+
: `export const modules = import.meta.glob("${options.rootDir}/*/blocks/**/fields.ts", { eager: false });`;
|
|
100
116
|
case virtualModules.thumbnails:
|
|
101
|
-
return
|
|
117
|
+
return shouldSkip("thumbnails")
|
|
118
|
+
? `export const modules = {};`
|
|
119
|
+
: `export const modules = import.meta.glob(["${options.rootDir}/*/blocks/**/thumbnail.png", "${options.rootDir}/*/thumbnail.jpg", "${options.rootDir}/*/thumbnail.png"], { eager: true });`;
|
|
102
120
|
case virtualModules.themes:
|
|
103
|
-
return
|
|
121
|
+
return shouldSkip("themes")
|
|
122
|
+
? `export const modules = {};`
|
|
123
|
+
: `export const modules = import.meta.glob("${options.rootDir}/**/theme.config.js", { eager: true });`;
|
|
104
124
|
default:
|
|
105
125
|
return undefined;
|
|
106
126
|
}
|