Skip to content

Commit

Permalink
build(projects): 引入@unocss/vite替换unocss,精简体积
Browse files Browse the repository at this point in the history
  • Loading branch information
honghuangdc committed Aug 31, 2022
1 parent 73ce53a commit 3540b75
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 7 deletions.
2 changes: 1 addition & 1 deletion build/plugins/index.ts
@@ -1,7 +1,7 @@
import type { PluginOption } from 'vite';
import vue from '@vitejs/plugin-vue';
import vueJsx from '@vitejs/plugin-vue-jsx';
import unocss from 'unocss/vite';
import unocss from '@unocss/vite';
import { VitePWA } from 'vite-plugin-pwa';
import progress from 'vite-plugin-progress';
import html from './html';
Expand Down
4 changes: 3 additions & 1 deletion package.json
Expand Up @@ -46,6 +46,7 @@
"typecheck": "vue-tsc --noEmit --skipLibCheck",
"lint": "eslint . --fix",
"prepare": "husky install",
"clean": "pnpm rimraf node_modules pnpm-lock.yaml",
"postinstall": "patch-package",
"release": "standard-version",
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0 && git add CHANGELOG.md"
Expand Down Expand Up @@ -89,6 +90,8 @@
"@types/node": "^18.7.14",
"@types/qs": "^6.9.7",
"@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-jsx": "^2.0.0",
"commitizen": "^4.2.5",
Expand All @@ -105,7 +108,6 @@
"sass": "^1.54.7",
"standard-version": "^9.5.0",
"typescript": "4.8.2",
"unocss": "^0.45.13",
"unplugin-icons": "^0.14.8",
"unplugin-vue-components": "0.22.4",
"unplugin-vue-define-options": "^0.11.1",
Expand Down
29 changes: 26 additions & 3 deletions src/views/component/table/index.vue
Expand Up @@ -14,8 +14,9 @@
</div>
</template>

<script setup lang="ts">
<script setup lang="tsx">
import { onMounted, ref } from 'vue';
import { NSpace, NButton, NPopconfirm } from 'naive-ui';
import type { DataTableColumn } from 'naive-ui';
import { useLoadingEmpty } from '@/hooks';
import { getRandomInteger } from '@/utils';
Expand All @@ -36,11 +37,33 @@ const columns: DataTableColumn[] = [
},
{
title: 'Age',
key: 'age'
key: 'age',
align: 'center'
},
{
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>
);
}
}
];
Expand Down
5 changes: 3 additions & 2 deletions uno.config.ts
@@ -1,7 +1,8 @@
import { defineConfig, presetUno } from 'unocss';
import { defineConfig } from '@unocss/vite';
import presetUno from '@unocss/preset-uno';

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' })],
shortcuts: {
'wh-full': 'w-full h-full',
Expand Down

1 comment on commit 3540b75

@vercel
Copy link

@vercel vercel bot commented on 3540b75 Aug 31, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.