Skip to content

Commit

Permalink
feat: 🚀 新增 vite-plugin-path 包
Browse files Browse the repository at this point in the history
  • Loading branch information
viarotel committed Oct 16, 2023
1 parent c1b2997 commit daa41fb
Show file tree
Hide file tree
Showing 11 changed files with 224 additions and 1 deletion.
4 changes: 4 additions & 0 deletions .yarnrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1

registry "https://registry.npmmirror.com/"
3 changes: 3 additions & 0 deletions packages/postcss-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,8 @@
"postcss-remove-inline-comments": "^0.0.2",
"postcss-scss": "^4.0.6"
},
"devDependencies": {
"unbuild": "latest"
},
"gitHead": "06c93c87769079a8837c3e7612448ffbaa80191c"
}
3 changes: 2 additions & 1 deletion packages/unocss-preset-shades/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"unocss": "^0.55.3"
},
"devDependencies": {
"@types/color": "^3.0.4"
"@types/color": "^3.0.4",
"unbuild": "latest"
}
}
3 changes: 3 additions & 0 deletions packages/utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,8 @@
"dependencies": {
"lodash-es": "^4.17.21",
"vue": "^3.3.4"
},
"devDependencies": {
"unbuild": "latest"
}
}
72 changes: 72 additions & 0 deletions packages/vite-plugin-path/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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))
38 changes: 38 additions & 0 deletions packages/vite-plugin-path/README.md
Original file line number Diff line number Diff line change
@@ -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"
```
12 changes: 12 additions & 0 deletions packages/vite-plugin-path/build.config.ts
Original file line number Diff line number Diff line change
@@ -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'],
})
50 changes: 50 additions & 0 deletions packages/vite-plugin-path/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"name": "@viarotel-org/vite-plugin-path",
"version": "0.7.4",
"description": "一个用于 Vitejs 的插件,可以返回任意文件的绝对路径。",
"author": "viarotel <[email protected]>",
"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"
}
}
13 changes: 13 additions & 0 deletions packages/vite-plugin-path/src/index.ts
Original file line number Diff line number Diff line change
@@ -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)}`
}
},
}
}
26 changes: 26 additions & 0 deletions packages/vite-plugin-path/tsconfig.json
Original file line number Diff line number Diff line change
@@ -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/**"
]
}
1 change: 1 addition & 0 deletions packages/vue-extends/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit daa41fb

Please sign in to comment.