vite-plugin-xq-cp-dep 1.1.0 → 1.1.2
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/index.cjs +12 -4
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +11 -4
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* vite-plugin-xq-cp-dep v1.1.
|
|
2
|
+
* vite-plugin-xq-cp-dep v1.1.2 (http://xqkeji.cn/)
|
|
3
3
|
* Author xqkeji.cn
|
|
4
4
|
* LICENSE SSPL-1.0
|
|
5
5
|
* Copyright 2026 xqkeji.cn
|
|
@@ -8,20 +8,28 @@
|
|
|
8
8
|
|
|
9
9
|
const path = require('path');
|
|
10
10
|
const fs = require('fs');
|
|
11
|
+
const node_url = require('node:url');
|
|
12
|
+
const node_path = require('node:path');
|
|
11
13
|
|
|
14
|
+
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
12
15
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
|
|
13
16
|
|
|
14
17
|
const path__default = /*#__PURE__*/_interopDefaultCompat(path);
|
|
15
18
|
const fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
|
|
16
19
|
|
|
17
|
-
const
|
|
20
|
+
const _dirname = node_path.dirname(node_url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href))));
|
|
21
|
+
const pkg_file = path__default.resolve(_dirname, "../../../package.json");
|
|
18
22
|
const pkg = JSON.parse(fs__default.readFileSync(pkg_file, "utf8"));
|
|
19
|
-
const node_modules_path = path__default.resolve(
|
|
23
|
+
const node_modules_path = path__default.resolve(_dirname, "../../../node_modules");
|
|
20
24
|
function xqCpDep() {
|
|
21
25
|
return {
|
|
22
26
|
name: "xq-cp-dep",
|
|
27
|
+
// 必须在 configResolved 里读 root:config 钩子阶段 root 尚未解析,
|
|
28
|
+
// 用户未显式设置 root 时 config.root 为 undefined,path.join 会抛
|
|
29
|
+
// "The 'path' argument must be of type string. Received undefined"。
|
|
30
|
+
// configResolved 阶段 root 已被 Vite 解析为绝对路径,永不为 undefined。
|
|
23
31
|
// @ts-ignore
|
|
24
|
-
|
|
32
|
+
configResolved(config) {
|
|
25
33
|
let root = config.root;
|
|
26
34
|
let publicDir = path__default.join(root, "public");
|
|
27
35
|
if (Object.prototype.hasOwnProperty.call(pkg, "dependencies")) {
|
package/dist/index.d.ts
CHANGED
package/dist/index.mjs
CHANGED
|
@@ -1,20 +1,27 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* vite-plugin-xq-cp-dep v1.1.
|
|
2
|
+
* vite-plugin-xq-cp-dep v1.1.2 (http://xqkeji.cn/)
|
|
3
3
|
* Author xqkeji.cn
|
|
4
4
|
* LICENSE SSPL-1.0
|
|
5
5
|
* Copyright 2026 xqkeji.cn
|
|
6
6
|
*/
|
|
7
7
|
import path from 'path';
|
|
8
8
|
import fs from 'fs';
|
|
9
|
+
import { fileURLToPath } from 'node:url';
|
|
10
|
+
import { dirname } from 'node:path';
|
|
9
11
|
|
|
10
|
-
const
|
|
12
|
+
const _dirname = dirname(fileURLToPath(import.meta.url));
|
|
13
|
+
const pkg_file = path.resolve(_dirname, "../../../package.json");
|
|
11
14
|
const pkg = JSON.parse(fs.readFileSync(pkg_file, "utf8"));
|
|
12
|
-
const node_modules_path = path.resolve(
|
|
15
|
+
const node_modules_path = path.resolve(_dirname, "../../../node_modules");
|
|
13
16
|
function xqCpDep() {
|
|
14
17
|
return {
|
|
15
18
|
name: "xq-cp-dep",
|
|
19
|
+
// 必须在 configResolved 里读 root:config 钩子阶段 root 尚未解析,
|
|
20
|
+
// 用户未显式设置 root 时 config.root 为 undefined,path.join 会抛
|
|
21
|
+
// "The 'path' argument must be of type string. Received undefined"。
|
|
22
|
+
// configResolved 阶段 root 已被 Vite 解析为绝对路径,永不为 undefined。
|
|
16
23
|
// @ts-ignore
|
|
17
|
-
|
|
24
|
+
configResolved(config) {
|
|
18
25
|
let root = config.root;
|
|
19
26
|
let publicDir = path.join(root, "public");
|
|
20
27
|
if (Object.prototype.hasOwnProperty.call(pkg, "dependencies")) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-plugin-xq-cp-dep",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"description": "A vite plugin that copies all package.json 'dependencies' and project 'assets' into the public directory.一个将 package.json 的 dependencies 全部依赖包和项目 assets 自动复制到 public 目录的 Vite 插件。",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|