From daa41fb718c883ea6aac0229af0ff2a08a65af71 Mon Sep 17 00:00:00 2001 From: viarotel Date: Mon, 16 Oct 2023 15:56:19 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=F0=9F=9A=80=20=E6=96=B0=E5=A2=9E=20vit?= =?UTF-8?q?e-plugin-path=20=E5=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .yarnrc | 4 ++ packages/postcss-config/package.json | 3 + packages/unocss-preset-shades/package.json | 3 +- packages/utils/package.json | 3 + packages/vite-plugin-path/CHANGELOG.md | 72 ++++++++++++++++++++++ packages/vite-plugin-path/README.md | 38 ++++++++++++ packages/vite-plugin-path/build.config.ts | 12 ++++ packages/vite-plugin-path/package.json | 50 +++++++++++++++ packages/vite-plugin-path/src/index.ts | 13 ++++ packages/vite-plugin-path/tsconfig.json | 26 ++++++++ packages/vue-extends/package.json | 1 + 11 files changed, 224 insertions(+), 1 deletion(-) create mode 100644 .yarnrc create mode 100644 packages/vite-plugin-path/CHANGELOG.md create mode 100644 packages/vite-plugin-path/README.md create mode 100644 packages/vite-plugin-path/build.config.ts create mode 100644 packages/vite-plugin-path/package.json create mode 100644 packages/vite-plugin-path/src/index.ts create mode 100644 packages/vite-plugin-path/tsconfig.json diff --git a/.yarnrc b/.yarnrc new file mode 100644 index 0000000..6733dfb --- /dev/null +++ b/.yarnrc @@ -0,0 +1,4 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + +registry "https://registry.npmmirror.com/" diff --git a/packages/postcss-config/package.json b/packages/postcss-config/package.json index 0926739..80a10a6 100644 --- a/packages/postcss-config/package.json +++ b/packages/postcss-config/package.json @@ -47,5 +47,8 @@ "postcss-remove-inline-comments": "^0.0.2", "postcss-scss": "^4.0.6" }, + "devDependencies": { + "unbuild": "latest" + }, "gitHead": "06c93c87769079a8837c3e7612448ffbaa80191c" } diff --git a/packages/unocss-preset-shades/package.json b/packages/unocss-preset-shades/package.json index dd9cd12..a048293 100644 --- a/packages/unocss-preset-shades/package.json +++ b/packages/unocss-preset-shades/package.json @@ -46,6 +46,7 @@ "unocss": "^0.55.3" }, "devDependencies": { - "@types/color": "^3.0.4" + "@types/color": "^3.0.4", + "unbuild": "latest" } } diff --git a/packages/utils/package.json b/packages/utils/package.json index 7f880b7..9714d1a 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -40,5 +40,8 @@ "dependencies": { "lodash-es": "^4.17.21", "vue": "^3.3.4" + }, + "devDependencies": { + "unbuild": "latest" } } diff --git a/packages/vite-plugin-path/CHANGELOG.md b/packages/vite-plugin-path/CHANGELOG.md new file mode 100644 index 0000000..a12bd14 --- /dev/null +++ b/packages/vite-plugin-path/CHANGELOG.md @@ -0,0 +1,72 @@ +# Change Log + +All notable changes to this project will be documented in this file. +See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. + +## [0.7.4](https://github.com/viarotel-org/packages/compare/v0.7.3...v0.7.4) (2023-09-08) + +**Note:** Version bump only for package @viarotel-org/unocss-preset-shades + + + + + + +## [0.7.3](https://github.com/viarotel-org/packages/compare/v0.7.2...v0.7.3) (2023-09-06) + + +### Performance Improvements + +* 🚀 unocss-preset-shades 性能优化 ([b45599c](https://github.com/viarotel-org/packages/commit/b45599caf57240b923504f497f16b40df5978fd2)) + + + + + +## [0.7.2](https://github.com/viarotel-org/packages/compare/v0.7.1...v0.7.2) (2023-09-06) + +**Note:** Version bump only for package @viarotel-org/unocss-preset-shades + + + + + +## [0.7.1](https://github.com/viarotel-org/packages/compare/v0.7.0...v0.7.1) (2023-09-06) + + +### Bug Fixes + +* 📝 修复 unocss-preset-shades 文档描述错误 ([6a29580](https://github.com/viarotel-org/packages/commit/6a2958070e58b2f6c0047f5ec9e66ec5df23f31b)) + + + + + +# [0.7.0](https://github.com/viarotel-org/packages/compare/v0.6.1...v0.7.0) (2023-09-05) + + +### Features + +* 🚀 unocss update ([073bec4](https://github.com/viarotel-org/packages/commit/073bec4f87dc68641fc15cefd5cc94320037e92e)) + + + + + +## [0.6.1](https://github.com/viarotel-org/packages/compare/v0.6.0...v0.6.1) (2023-09-05) + + +### Bug Fixes + +* 🔧 unocss-preset-shades 补全 ts 类型 以解决使用时编辑器报错的问题 ([5d5b63f](https://github.com/viarotel-org/packages/commit/5d5b63f303a2144cd97729893a87533dcbbc9ff9)) + + + + + +# [0.6.0](https://github.com/viarotel-org/packages/compare/v0.5.11...v0.6.0) (2023-09-05) + + +### Features + +* 📦️ add unocss-preset-shades ([7356cff](https://github.com/viarotel-org/packages/commit/7356cffb51fa5a046abb05443f003394770d4b2c)) diff --git a/packages/vite-plugin-path/README.md b/packages/vite-plugin-path/README.md new file mode 100644 index 0000000..c9fc6bb --- /dev/null +++ b/packages/vite-plugin-path/README.md @@ -0,0 +1,38 @@ +# vite-plugin-path + +🔍 一个用于 Vitejs 的插件,可以返回任意文件的绝对路径。 + +🔍 A plugin for Vitejs can return the absolute path of any file. + +## 安装 + +```shell +npm install @viarotel-org/vite-plugin-path +``` + +## 示例 + +首先使用该插件 + +```js +// vite.config.js +import { defineConfig } from 'vite' +import useVitePluginPath from '@viarotel-org/vite-plugin-path' + +export default defineConfig({ + // ... + plugins: [useVitePluginPath()], + // ... +}) +``` + +然后导入需要获取绝对路径的文件 + +```js +// Demo.js +import examplePath from '../../example.exe?path' + +console.log(examplePath) + +// 将输出 "C:/User/packages/vite-plugin-path/example.exe" +``` diff --git a/packages/vite-plugin-path/build.config.ts b/packages/vite-plugin-path/build.config.ts new file mode 100644 index 0000000..0690e18 --- /dev/null +++ b/packages/vite-plugin-path/build.config.ts @@ -0,0 +1,12 @@ +import { defineBuildConfig } from 'unbuild' + +export default defineBuildConfig({ + entries: ['./src/index'], + declaration: true, + clean: true, + failOnWarn: false, + rollup: { + emitCJS: true, + }, + externals: ['vite'], +}) diff --git a/packages/vite-plugin-path/package.json b/packages/vite-plugin-path/package.json new file mode 100644 index 0000000..feced98 --- /dev/null +++ b/packages/vite-plugin-path/package.json @@ -0,0 +1,50 @@ +{ + "name": "@viarotel-org/vite-plugin-path", + "version": "0.7.4", + "description": "一个用于 Vitejs 的插件,可以返回任意文件的绝对路径。", + "author": "viarotel ", + "license": "MIT", + "homepage": "https://github.com/viarotel-org/packages/tree/main/packages/vite-plugin-path#readme", + "repository": { + "type": "git", + "url": "git+https://github.com/viarotel-org/packages.git" + }, + "bugs": { + "url": "https://github.com/viarotel-org/packages/issues" + }, + "keywords": [ + "unocss", + "preset", + "shade", + "color", + "primary", + "theme" + ], + "exports": { + ".": { + "require": "./dist/index.cjs", + "import": "./dist/index.mjs" + }, + "./*": "./dist/*", + "./dist/*": "./dist/*", + "./src/*": "./src/*" + }, + "publishConfig": { + "access": "public" + }, + "main": "dist/index.cjs", + "module": "dist/index.mjs", + "files": [ + "dist", + "src" + ], + "scripts": { + "build": "unbuild" + }, + "dependencies": { + "vite": "^4.4.0" + }, + "devDependencies": { + "unbuild": "latest" + } +} diff --git a/packages/vite-plugin-path/src/index.ts b/packages/vite-plugin-path/src/index.ts new file mode 100644 index 0000000..a695c02 --- /dev/null +++ b/packages/vite-plugin-path/src/index.ts @@ -0,0 +1,13 @@ +import type { Plugin } from 'vite' + +export default function VitePluginPath(): Plugin { + return { + name: 'vite-plugin-path', + transform(src, id) { + if (id.endsWith('?path')) { + const value = id.slice(0, -5) + return `export default ${JSON.stringify(value)}` + } + }, + } +} diff --git a/packages/vite-plugin-path/tsconfig.json b/packages/vite-plugin-path/tsconfig.json new file mode 100644 index 0000000..2610f1d --- /dev/null +++ b/packages/vite-plugin-path/tsconfig.json @@ -0,0 +1,26 @@ +{ + "compilerOptions": { + "target": "es2018", + "module": "esnext", + "lib": ["esnext", "dom"], + "moduleResolution": "node", + "esModuleInterop": true, + "strict": true, + "strictNullChecks": true, + "resolveJsonModule": true, + "skipLibCheck": true, + "skipDefaultLibCheck": true, + "jsx": "preserve", + "types": ["node", "vite/client"], + "paths": {} + }, + "exclude": [ + "**/dist/**", + "**/node_modules/**", + "**/client/**", + "**/playground/**", + "**/examples/**", + "**/interactive/**", + "**/test/dts/**" + ] +} diff --git a/packages/vue-extends/package.json b/packages/vue-extends/package.json index 123d997..afba86c 100644 --- a/packages/vue-extends/package.json +++ b/packages/vue-extends/package.json @@ -80,6 +80,7 @@ "@viarotel-org/unocss-config": "^0.7.4", "@viarotel-org/vite-config-vue": "^0.7.0", "cross-env": "^7.0.3", + "unbuild": "latest", "vite": "^4.4.0", "vite-plugin-eslint": "^1.8.1", "vue2": "npm:vue@~2.6.14",