@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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/vite/index.js +13 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iservice-dev/is-wp-plugin-kit",
3
- "version": "1.6.4",
3
+ "version": "1.6.6",
4
4
  "description": "A toolkit for WordPress plugin development with Vite, TypeScript, and modern build tools",
5
5
  "type": "module",
6
6
  "main": "vite/index.js",
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: staticCopyTargets })],
108
+ plugins: [viteStaticCopy({ targets: validTargets })],
98
109
 
99
110
  ...userOptions,
100
111
  });