build(projects): 引入@unocss/vite替换unocss,精简体积

This commit is contained in:
Soybean 2022-08-31 23:29:37 +08:00
parent 73ce53a388
commit 3540b75557
4 changed files with 33 additions and 7 deletions

View File

@ -1,7 +1,7 @@
import type { PluginOption } from 'vite'; import type { PluginOption } from 'vite';
import vue from '@vitejs/plugin-vue'; import vue from '@vitejs/plugin-vue';
import vueJsx from '@vitejs/plugin-vue-jsx'; import vueJsx from '@vitejs/plugin-vue-jsx';
import unocss from 'unocss/vite'; import unocss from '@unocss/vite';
import { VitePWA } from 'vite-plugin-pwa'; import { VitePWA } from 'vite-plugin-pwa';
import progress from 'vite-plugin-progress'; import progress from 'vite-plugin-progress';
import html from './html'; import html from './html';

View File

@ -46,6 +46,7 @@
"typecheck": "vue-tsc --noEmit --skipLibCheck", "typecheck": "vue-tsc --noEmit --skipLibCheck",
"lint": "eslint . --fix", "lint": "eslint . --fix",
"prepare": "husky install", "prepare": "husky install",
"clean": "pnpm rimraf node_modules pnpm-lock.yaml",
"postinstall": "patch-package", "postinstall": "patch-package",
"release": "standard-version", "release": "standard-version",
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0 && git add CHANGELOG.md" "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0 && git add CHANGELOG.md"
@ -89,6 +90,8 @@
"@types/node": "^18.7.14", "@types/node": "^18.7.14",
"@types/qs": "^6.9.7", "@types/qs": "^6.9.7",
"@types/ua-parser-js": "^0.7.36", "@types/ua-parser-js": "^0.7.36",
"@unocss/preset-uno": "^0.45.13",
"@unocss/vite": "^0.45.13",
"@vitejs/plugin-vue": "^3.0.3", "@vitejs/plugin-vue": "^3.0.3",
"@vitejs/plugin-vue-jsx": "^2.0.0", "@vitejs/plugin-vue-jsx": "^2.0.0",
"commitizen": "^4.2.5", "commitizen": "^4.2.5",
@ -105,7 +108,6 @@
"sass": "^1.54.7", "sass": "^1.54.7",
"standard-version": "^9.5.0", "standard-version": "^9.5.0",
"typescript": "4.8.2", "typescript": "4.8.2",
"unocss": "^0.45.13",
"unplugin-icons": "^0.14.8", "unplugin-icons": "^0.14.8",
"unplugin-vue-components": "0.22.4", "unplugin-vue-components": "0.22.4",
"unplugin-vue-define-options": "^0.11.1", "unplugin-vue-define-options": "^0.11.1",

View File

@ -14,8 +14,9 @@
</div> </div>
</template> </template>
<script setup lang="ts"> <script setup lang="tsx">
import { onMounted, ref } from 'vue'; import { onMounted, ref } from 'vue';
import { NSpace, NButton, NPopconfirm } from 'naive-ui';
import type { DataTableColumn } from 'naive-ui'; import type { DataTableColumn } from 'naive-ui';
import { useLoadingEmpty } from '@/hooks'; import { useLoadingEmpty } from '@/hooks';
import { getRandomInteger } from '@/utils'; import { getRandomInteger } from '@/utils';
@ -36,11 +37,33 @@ const columns: DataTableColumn[] = [
}, },
{ {
title: 'Age', title: 'Age',
key: 'age' key: 'age',
align: 'center'
}, },
{ {
title: 'Address', title: 'Address',
key: 'address' key: 'address',
align: 'center'
},
{
key: 'action',
title: 'Action',
align: 'center',
render: () => {
return (
<NSpace justify={'center'}>
<NButton size={'small'} onClick={() => {}}>
编辑
</NButton>
<NPopconfirm onPositiveClick={() => {}}>
{{
default: () => '确认删除',
trigger: () => <NButton size={'small'}>删除</NButton>
}}
</NPopconfirm>
</NSpace>
);
}
} }
]; ];

View File

@ -1,7 +1,8 @@
import { defineConfig, presetUno } from 'unocss'; import { defineConfig } from '@unocss/vite';
import presetUno from '@unocss/preset-uno';
export default defineConfig({ export default defineConfig({
exclude: ['node_modules', '.git', '.husky', '.vscode', 'dist', 'public', 'build', 'mock', './stats.html'], exclude: ['node_modules', 'dist', '.git', '.husky', '.vscode', 'public', 'build', 'mock', './stats.html'],
presets: [presetUno({ dark: 'class' })], presets: [presetUno({ dark: 'class' })],
shortcuts: { shortcuts: {
'wh-full': 'w-full h-full', 'wh-full': 'w-full h-full',