Skip to content

Commit 3b35f07

Browse files
committed
update : local import readme.md
1 parent 0fdadab commit 3b35f07

File tree

9 files changed

+102
-13
lines changed

9 files changed

+102
-13
lines changed

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,31 @@ pnpm build
4848

4949
3. 本地引入打包的源代码
5050

51+
cd到你构建好的目录(默认是dist),然后输入以下命令
52+
53+
```sh
54+
pnpm link -g # 当前是在构建好的dist目录下
55+
```
56+
57+
然后在你需要使用的项目中添加刚才link的包
58+
59+
```sh
60+
pnpm link -g licht-ui # 你需要使用licht-ui的项目下
61+
```
62+
63+
最后在项目入口处全局导入
64+
65+
```ts
66+
import { createApp } from "vue";
67+
import LichtUI from "licht-ui/components"; // 导入组件
68+
import "licht-ui/style/style.css"; // 导入样式
69+
import "./style.css";
70+
import App from "./App.vue";
71+
72+
createApp(App).use(LichtUI).mount("#app");
73+
```
74+
75+
5176

5277
## 关于
5378

dist.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "licht-design",
2+
"name": "licht-ui",
33
"version": "1.0.0",
44
"description": "Licht UI 是一个基于Vue3开发的轻量级组件库",
55
"scripts": {

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "licht-design",
2+
"name": "licht-ui",
33
"version": "1.0.0",
44
"description": "Licht UI 是一个基于Vue3开发的轻量级组件库",
55
"scripts": {
@@ -32,6 +32,7 @@
3232
"@licht-ui/components": "workspace:^",
3333
"@licht-ui/theme-chalk": "workspace:^",
3434
"@licht-ui/utils": "workspace:^",
35+
"dist": "link:E:/编程练习/LichtUI/dist",
3536
"lodash-unified": "^1.0.3",
3637
"shiki": "^1.22.2",
3738
"typescript": "^5.6.3",

packages/components/avatar/src/avatar.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ export const avatarProp = {
99
type: String as PropType<(typeof sizeProp)[number]>,
1010
default: "middle",
1111
},
12-
styleImg: {
13-
type: Object as PropType<StyleValue>,
14-
},
12+
styleImg: Object as PropType<StyleValue>,
1513
name: String,
1614
src: String,
1715
round: Boolean,

packages/components/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"name": "@licht-ui/components",
33
"version": "1.0.0",
4-
"main": "index.js",
5-
"module": "index.js",
6-
"types": "types/index.d.ts",
4+
"main": "./index.es.js",
5+
"module": "./index.es.js",
6+
"types": "./index.d.ts",
77
"description": "",
88
"keywords": [],
99
"author": "",

packages/theme-chalk/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
"name": "@licht-ui/theme-chalk",
33
"version": "1.0.0",
44
"description": "",
5+
"main": "./index.es.js",
6+
"module": "./index.es.js",
57
"types": "./index.d.ts",
68
"keywords": [],
79
"author": "",

pnpm-lock.yaml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

script/build.ts

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import { readdirSync, copyFileSync } from "fs";
1+
import { readdirSync, copyFileSync, mkdirSync } from "fs";
22
import { build, defineConfig } from "vite";
33
import vue from "@vitejs/plugin-vue";
44
import dts from "vite-plugin-dts";
5+
import { copyDirSync, deleteFolderRecursive } from "./utiles";
56

67
const DefineOptions = require("unplugin-vue-define-options/vite");
78
const path = require("path");
@@ -41,17 +42,22 @@ async function main() {
4142
}),
4243
],
4344
build: {
44-
commonjsOptions: {
45-
include: [/docs/, /node_modules/, /play/],
46-
},
4745
lib: {
4846
entry,
4947
name: "licht-ui",
5048
fileName: (format: any) => `index.${format}.js`,
51-
formats: ["cjs", "es", "umd"],
49+
formats: ["es", "umd"],
5250
},
5351
outDir: packageOutDir,
5452
emptyOutDir: true,
53+
chunkSizeWarningLimit: 1500,
54+
terserOptions: {
55+
compress: {
56+
drop_console: true,
57+
58+
drop_debugger: true,
59+
},
60+
},
5561
rollupOptions: {
5662
external: ["vue"],
5763
output: {
@@ -68,6 +74,12 @@ async function main() {
6874
resolve(packageRoot + "/package.json"),
6975
resolve(`./${buildDir}/${i}/package.json`)
7076
);
77+
mkdirSync(resolve(`./${buildDir}/style`), { recursive: true });
78+
copyDirSync(
79+
resolve(`${packageOutDir}/style`),
80+
resolve(`./${buildDir}/style`)
81+
);
82+
deleteFolderRecursive(resolve(`${packageOutDir}/style`));
7183
}
7284
}
7385
main();

script/utiles.ts

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import {
2+
existsSync,
3+
readdirSync,
4+
lstatSync,
5+
unlinkSync,
6+
rmdirSync,
7+
copyFileSync,
8+
} from "fs";
9+
const path = require("path");
10+
11+
export function deleteFolderRecursive(path: string) {
12+
if (existsSync(path)) {
13+
readdirSync(path).forEach(function (file: string) {
14+
const curPath = path + "/" + file;
15+
if (lstatSync(curPath).isDirectory()) {
16+
// recurse
17+
deleteFolderRecursive(curPath);
18+
} else {
19+
// delete file
20+
unlinkSync(curPath);
21+
}
22+
});
23+
rmdirSync(path);
24+
}
25+
}
26+
27+
export function copyDirSync(src: string, dest: string) {
28+
// 检查源目录是否存在
29+
if (!existsSync(src)) {
30+
return;
31+
}
32+
33+
// 读取源目录内容
34+
const entries = readdirSync(src, { withFileTypes: true });
35+
36+
for (let entry of entries) {
37+
const srcPath = path.join(src, entry.name);
38+
const destPath = path.join(dest, entry.name);
39+
40+
if (entry.isDirectory()) {
41+
// 如果是目录,递归复制
42+
copyDirSync(srcPath, destPath);
43+
} else {
44+
// 如果是文件,直接复制
45+
copyFileSync(srcPath, destPath);
46+
}
47+
}
48+
}

0 commit comments

Comments
 (0)