diff --git a/build/demoCopy.js b/build/demoCopy.js new file mode 100644 index 00000000..1282e646 --- /dev/null +++ b/build/demoCopy.js @@ -0,0 +1,37 @@ +/* + * @Author: weisheng + * @Date: 2022-12-02 14:34:18 + * @LastEditTime: 2023-07-22 15:27:13 + * @LastEditors: weisheng + * @Description: .d.ts移动到制品 + * @FilePath: \wot-design-uni\build\demoCopy.js + * 记得注释 + */ +const fs = require('fs') +const path = require('path') +const srcRoot = path.join(__dirname, '../dist/build/h5') +const targetSrcRoot = path.join(__dirname, '../docs/dist/demo') + +function copyFolder(sourceDir, targetDir) { + // 创建目标文件夹 + fs.mkdirSync(targetDir, { recursive: true }) + + // 读取源文件夹中的文件和子文件夹列表 + const fileNames = fs.readdirSync(sourceDir) + + fileNames.forEach((fileName) => { + const sourcePath = path.join(sourceDir, fileName) + const targetPath = path.join(targetDir, fileName) + + // 判断文件是文件夹还是文件 + if (fs.statSync(sourcePath).isDirectory()) { + // 如果是文件夹,则递归调用 copyFolder 函数 + copyFolder(sourcePath, targetPath) + } else { + // 如果是文件,则直接复制文件 + fs.copyFileSync(sourcePath, targetPath) + } + }) +} + +copyFolder(srcRoot, targetSrcRoot) diff --git a/docs/package.json b/docs/package.json index 9f68e298..32c1939f 100644 --- a/docs/package.json +++ b/docs/package.json @@ -4,7 +4,7 @@ "description": "A ui component library for mini program", "scripts": { "dev:docs": "webpack-dev-server --progress --config build/webpack.docs.conf.js", - "build:docs": "rimraf docs/dist && cross-env NODE_ENV=production webpack --progress --config build/webpack.docs.conf.js" + "build:docs": "rimraf dist && cross-env NODE_ENV=production webpack --progress --config build/webpack.docs.conf.js" }, "license": "ISC", "devDependencies": { diff --git a/package.json b/package.json index 818969dc..19813476 100644 --- a/package.json +++ b/package.json @@ -36,6 +36,7 @@ "build:quickapp-webview-union": "uni build -p quickapp-webview-union", "type-check": "vue-tsc --noEmit", "dev:docs": "cd docs && npm run dev:docs", + "build:docs": "npm run build:h5 && cd docs && npm run build:docs && cd .. && node build/demoCopy.js", "prepare": "husky install && cd docs && yarn install || npm install", "lint": "eslint --fix --ext .js,.vue,.ts src", "commit": "git-cz",