vite-plugin-xq-cp-dep 1.0.3 → 1.0.4
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/README.md +3 -2
- package/dist/index.cjs +17 -4
- package/dist/index.d.ts +2 -2
- package/dist/index.mjs +17 -4
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# vite-plugin-xq-cp-dep
|
|
2
2
|
|
|
3
|
-
A vite copy all package.json config item 'dependencies' to public directory plugin.
|
|
3
|
+
A vite copy all package.json config item 'dependencies' and project directory 'src/assets' to public directory plugin.
|
|
4
4
|
|
|
5
|
-
一个将package.json配置文件中配置的'dependencies'
|
|
5
|
+
一个将package.json配置文件中配置的'dependencies'的所有依赖包和项目目录'src/assets'自动复制到public目录的插件。
|
|
6
6
|
|
|
7
7
|
## 安装
|
|
8
8
|
```bash
|
|
@@ -65,3 +65,4 @@ package.json配置示例:
|
|
|
65
65
|
|
|
66
66
|
### 如果复制的目录目标目录已经存在,将会跳过操作。
|
|
67
67
|
### 例如:复制'node_modules/bootstrap'目录到public目录下时,'public/bootstrap'目录已经存在,将会被跳过。如果需要更新,则需要将'public/bootstrap'手动删除。
|
|
68
|
+
### 如果项目目录'src/assets'存在,整个目录也会被复制到public目录下。
|
package/dist/index.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* vite-plugin-xq-cp-dep v1.0.
|
|
2
|
+
* vite-plugin-xq-cp-dep v1.0.4 (http://xqkeji.cn/)
|
|
3
3
|
* Author xqkeji.cn
|
|
4
4
|
* LICENSE SSPL-1.0
|
|
5
|
-
* Copyright
|
|
5
|
+
* Copyright 2023 xqkeji.cn
|
|
6
6
|
*/
|
|
7
7
|
'use strict';
|
|
8
8
|
|
|
@@ -16,10 +16,10 @@ function xqCpDep() {
|
|
|
16
16
|
return {
|
|
17
17
|
name: "xq-cp-dep",
|
|
18
18
|
config(config) {
|
|
19
|
+
let root = config.root;
|
|
20
|
+
let publicDir = path.join(root, "public");
|
|
19
21
|
if (Object.prototype.hasOwnProperty.call(pkg, "dependencies")) {
|
|
20
22
|
const deps = pkg.dependencies;
|
|
21
|
-
let root = config.root;
|
|
22
|
-
let publicDir = path.join(root, "public");
|
|
23
23
|
if (!fs.existsSync(publicDir)) {
|
|
24
24
|
fs.mkdirSync(publicDir);
|
|
25
25
|
}
|
|
@@ -35,6 +35,19 @@ function xqCpDep() {
|
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
|
+
let srcDir = path.join(root, "src");
|
|
39
|
+
let assetsDir = path.join(srcDir, "assets");
|
|
40
|
+
let destAssetsDir = path.join(publicDir, "assets");
|
|
41
|
+
if (!fs.existsSync(publicDir)) {
|
|
42
|
+
fs.mkdirSync(publicDir);
|
|
43
|
+
}
|
|
44
|
+
if (fs.existsSync(assetsDir) && !fs.existsSync(destAssetsDir)) {
|
|
45
|
+
fs.cp(assetsDir, destAssetsDir, { recursive: true }, (err) => {
|
|
46
|
+
if (err) {
|
|
47
|
+
console.error(err);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
38
51
|
}
|
|
39
52
|
};
|
|
40
53
|
}
|
package/dist/index.d.ts
CHANGED
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* vite-plugin-xq-cp-dep v1.0.
|
|
2
|
+
* vite-plugin-xq-cp-dep v1.0.4 (http://xqkeji.cn/)
|
|
3
3
|
* Author xqkeji.cn
|
|
4
4
|
* LICENSE SSPL-1.0
|
|
5
|
-
* Copyright
|
|
5
|
+
* Copyright 2023 xqkeji.cn
|
|
6
6
|
*/
|
|
7
7
|
import path from 'path';
|
|
8
8
|
import fs from 'fs';
|
|
@@ -14,10 +14,10 @@ function xqCpDep() {
|
|
|
14
14
|
return {
|
|
15
15
|
name: "xq-cp-dep",
|
|
16
16
|
config(config) {
|
|
17
|
+
let root = config.root;
|
|
18
|
+
let publicDir = path.join(root, "public");
|
|
17
19
|
if (Object.prototype.hasOwnProperty.call(pkg, "dependencies")) {
|
|
18
20
|
const deps = pkg.dependencies;
|
|
19
|
-
let root = config.root;
|
|
20
|
-
let publicDir = path.join(root, "public");
|
|
21
21
|
if (!fs.existsSync(publicDir)) {
|
|
22
22
|
fs.mkdirSync(publicDir);
|
|
23
23
|
}
|
|
@@ -33,6 +33,19 @@ function xqCpDep() {
|
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
|
+
let srcDir = path.join(root, "src");
|
|
37
|
+
let assetsDir = path.join(srcDir, "assets");
|
|
38
|
+
let destAssetsDir = path.join(publicDir, "assets");
|
|
39
|
+
if (!fs.existsSync(publicDir)) {
|
|
40
|
+
fs.mkdirSync(publicDir);
|
|
41
|
+
}
|
|
42
|
+
if (fs.existsSync(assetsDir) && !fs.existsSync(destAssetsDir)) {
|
|
43
|
+
fs.cp(assetsDir, destAssetsDir, { recursive: true }, (err) => {
|
|
44
|
+
if (err) {
|
|
45
|
+
console.error(err);
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
}
|
|
36
49
|
}
|
|
37
50
|
};
|
|
38
51
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-plugin-xq-cp-dep",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "A vite copy all package.json config item 'dependencies' to public directory plugin
|
|
3
|
+
"version": "1.0.4",
|
|
4
|
+
"description": "A vite copy all package.json config item 'dependencies' and project directory 'src/assets' to public directory plugin.一个将package.json配置文件中配置的'dependencies'的所有依赖包和项目目录'src/assets'自动复制到public目录的插件。",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
7
7
|
"dist"
|
|
@@ -28,7 +28,8 @@
|
|
|
28
28
|
"vite-plugin",
|
|
29
29
|
"vite-cp",
|
|
30
30
|
"cp-dependencies-to-public",
|
|
31
|
-
"cp-to-public"
|
|
31
|
+
"cp-to-public",
|
|
32
|
+
"cp-src-assets-to-public"
|
|
32
33
|
],
|
|
33
34
|
"author": "xqkeji.cn",
|
|
34
35
|
"license": "SSPL-1.0",
|