From 8d62bec64560018f0bc7f0069f5508786c28bd1e Mon Sep 17 00:00:00 2001 From: zhaojinfeng <121016171@qq.com> Date: Fri, 21 Jul 2023 14:47:54 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20unocss=20=E4=B8=8D=E7=94=9F=E6=95=88?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/build.ts | 14 +++++++++----- extra/unocss.ts | 1 + 2 files changed, 10 insertions(+), 5 deletions(-) create mode 100644 extra/unocss.ts diff --git a/bin/build.ts b/bin/build.ts index 8d3e277..c84300f 100644 --- a/bin/build.ts +++ b/bin/build.ts @@ -2,7 +2,7 @@ * @Author: zhaojinfeng 121016171@qq.com * @Date: 2023-06-19 10:38:07 * @LastEditors: zhaojinfeng 121016171@qq.com - * @LastEditTime: 2023-07-21 04:26:58 + * @LastEditTime: 2023-07-21 14:47:27 * @FilePath: \vue3\bin\build.ts * @Description: * @@ -13,14 +13,15 @@ import { outputFile, readdir, remove } from 'fs-extra' import { build } from 'vite' import { renderFile } from 'ejs' import consola from 'consola' +import Unocss from 'unocss/vite' -function buildAComponent(name: string) { - build({ +async function buildAComponent(name: string) { + await build({ build: { outDir: `es/${name}`, lib: { - name: 'tianheng-design', - entry: resolve(process.cwd(), 'packages', name, 'index.vue'), + name: 'thzxcx', + entry: [resolve(process.cwd(), 'packages', name, 'index.vue'), resolve(process.cwd(), 'extra', 'unocss.ts')], fileName: 'index', }, rollupOptions: { @@ -39,7 +40,10 @@ function buildAComponent(name: string) { ], }, }, + plugins: [Unocss()], }) + await Promise.all([remove(`es/${name}/index2.mjs`), remove(`es/${name}/unocss.mjs`), remove(`lib/${name}/index2.mjs`), remove(`lib/${name}/unocss.mjs`)]) + consola.success(`${name}构建成功!`) } function dirPathToName(dirPath: string) { diff --git a/extra/unocss.ts b/extra/unocss.ts new file mode 100644 index 0000000..390481d --- /dev/null +++ b/extra/unocss.ts @@ -0,0 +1 @@ +import 'uno.css'