@iservice-dev/is-wp-plugin-kit 1.6.4 → 1.6.6
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/package.json +1 -1
- package/vite/index.js +13 -2
package/package.json
CHANGED
package/vite/index.js
CHANGED
|
@@ -43,6 +43,13 @@ export function wpPluginKitVite(userOptions = {}) {
|
|
|
43
43
|
{ src: "assets/src/legacy/js/*.js", dest: "js" },
|
|
44
44
|
];
|
|
45
45
|
|
|
46
|
+
// Filter out targets where source path doesn't exist or has no files
|
|
47
|
+
const cwd = userOptions.cwd ?? process.cwd();
|
|
48
|
+
const validTargets = staticCopyTargets.filter((target) => {
|
|
49
|
+
const files = fg.sync(target.src, { cwd });
|
|
50
|
+
return files.length > 0;
|
|
51
|
+
});
|
|
52
|
+
|
|
46
53
|
return defineConfig({
|
|
47
54
|
base: "./",
|
|
48
55
|
|
|
@@ -54,7 +61,6 @@ export function wpPluginKitVite(userOptions = {}) {
|
|
|
54
61
|
cors: true,
|
|
55
62
|
hmr: { host: "localhost", protocol: "ws" },
|
|
56
63
|
},
|
|
57
|
-
|
|
58
64
|
build: {
|
|
59
65
|
outDir: userOptions.outDir ?? "assets/dist",
|
|
60
66
|
assetsDir: "",
|
|
@@ -64,9 +70,14 @@ export function wpPluginKitVite(userOptions = {}) {
|
|
|
64
70
|
cssCodeSplit: true,
|
|
65
71
|
rollupOptions: {
|
|
66
72
|
input: makeInputs(),
|
|
73
|
+
external: ['jquery', 'select2'],
|
|
67
74
|
output: {
|
|
68
75
|
intro: "(function(){",
|
|
69
76
|
outro: "})();",
|
|
77
|
+
globals: {
|
|
78
|
+
jquery: 'jQuery',
|
|
79
|
+
select2: 'select2'
|
|
80
|
+
},
|
|
70
81
|
entryFileNames: (chunk) =>
|
|
71
82
|
chunk.name.startsWith("js/") ? "[name].js" : "js/[name].js",
|
|
72
83
|
chunkFileNames: "js/[name]-[hash].js",
|
|
@@ -94,7 +105,7 @@ export function wpPluginKitVite(userOptions = {}) {
|
|
|
94
105
|
|
|
95
106
|
css: { postcss: "./postcss.config.cjs" },
|
|
96
107
|
|
|
97
|
-
plugins: [viteStaticCopy({ targets:
|
|
108
|
+
plugins: [viteStaticCopy({ targets: validTargets })],
|
|
98
109
|
|
|
99
110
|
...userOptions,
|
|
100
111
|
});
|