build(deps): add auto-import

This commit is contained in:
chen.home 2023-06-15 23:23:30 +08:00
parent 2f7e871d3d
commit 86df69c037
9 changed files with 36 additions and 25 deletions

1
.gitignore vendored
View File

@ -26,6 +26,7 @@ stats.html
*.sw?
/src/typings/components.d.ts
/src/typings/auto-imports.d.ts
pnpm-lock.yaml
package-lock.json
yarn.lock

View File

@ -1,6 +1,6 @@
MIT License
Copyright (c) 2021 Soybean
Copyright (c) 2021 Rock chen
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@ -1,11 +1,12 @@
import type { PluginOption } from 'vite'
import unocss from '@unocss/vite'
import UnoCSS from '@unocss/vite'
import vueSetupExtend from 'vite-plugin-vue-setup-extend'
import vue from './vue'
import compress from './compress'
import visualizer from './visualizer'
import unplugin from './unplugin'
import mock from './mock'
// import { viteMockServe } from 'vite-plugin-mock' // https://github.com/vbenjs/vite-plugin-mock/blob/main/README.zh_CN.md
/**
* @description: vite插件配置
@ -13,7 +14,7 @@ import mock from './mock'
* @return {*}
*/
export function setVitePlugins(env: ImportMetaEnv) {
const plugins: PluginOption[] = [...vue, unocss(), ...unplugin, mock, vueSetupExtend()]
const plugins: PluginOption[] = [...vue, UnoCSS(), ...unplugin,mock, vueSetupExtend()]
// 是否压缩
if (env.VITE_COMPRESS_OPEN === 'Y')
plugins.push(compress(env))

View File

@ -2,5 +2,6 @@ import { viteMockServe } from 'vite-plugin-mock' // https://github.com/vbenjs/vi
export default viteMockServe({
mockPath: 'mock',
injectCode: 'import { setupMockServer } from \'../mock\';setupMockServer();',
enable: true,
// watchFiles: false,
})

View File

@ -1,5 +1,6 @@
import path from 'node:path'
import Components from 'unplugin-vue-components/vite'
import AutoImport from 'unplugin-auto-import/vite'
import { NaiveUiResolver } from 'unplugin-vue-components/resolvers'
import Icons from 'unplugin-icons/vite' // https://github.com/antfu/unplugin-icons
@ -8,6 +9,15 @@ import IconsResolver from 'unplugin-icons/resolver'
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons' // https://github.com/vbenjs/vite-plugin-svg-icons/blob/main/README.zh_CN.md
export default [
AutoImport({
imports: ['vue', 'vue-router','@vueuse/core','pinia'],
include: [
/\.[tj]sx?$/,
/\.vue$/,
/\.vue\?vue/,
/\.md$/],
dts: 'src/typings/auto-imports.d.ts',
}),
Components({
dts: 'src/typings/components.d.ts',
resolvers: [IconsResolver(), NaiveUiResolver()],

View File

@ -1,6 +1,7 @@
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx' // https://github.com/vitejs/vite/tree/main/packages/plugin-vue-jsx
import VueDevTools from 'vite-plugin-vue-devtools' // https://github.com/webfansplz/vite-plugin-vue-devtools
const plugins = [vue(), vueJsx()]
const plugins = [vue(), vueJsx(),VueDevTools()]
export default plugins

View File

@ -1,6 +1,6 @@
{
"name": "ench-admin",
"version": "0.0.1",
"version": "0.1.0",
"private": true,
"description": "",
"author": {
@ -57,28 +57,25 @@
"@wangeditor/editor-for-vue": "^5.1.12",
"axios": "^1.4.0",
"crypto-js": "^4.1.1",
"echarts": "^5.4.1",
"echarts": "^5.4.2",
"md-editor-v3": "^2.9.3",
"pinia": "^2.1.3",
"pinia-plugin-persist": "^1.0.0",
"qs": "^6.11.1",
"vue": "^3.3.4",
"vue-qr": "^4.0.9",
"vue-router": "^4.1.6"
"vue-router": "^4.2.2"
},
"devDependencies": {
"@chansee97/commitlint-config": "^0.3.3",
"@chansee97/eslint-config-vue": "^0.3.3",
"@commitlint/cli": "^17.4.1",
"@iconify-json/icon-park-outline": "^1.1.9",
"@iconify/vue": "^4.0.2",
"@commitlint/cli": "^17.6.5",
"@iconify-json/icon-park-outline": "^1.1.11",
"@iconify/vue": "^4.1.1",
"@types/crypto-js": "^4.1.1",
"@types/mockjs": "^1.0.7",
"@types/node": "^18.15.3",
"@types/node": "^20.3.1",
"@types/qs": "^6.9.7",
"@unocss/preset-attributify": "^0.50.4",
"@unocss/preset-uno": "^0.50.4",
"@unocss/vite": "^0.50.4",
"@vitejs/plugin-vue": "^4.0.0",
"@vitejs/plugin-vue-jsx": "^3.0.0",
"commitizen": "^4.2.6",
@ -91,13 +88,16 @@
"naive-ui": "^2.34.4",
"rollup-plugin-visualizer": "^5.9.0",
"simple-git-hooks": "^2.8.1",
"typescript": "^5.0.4",
"unplugin-icons": "^0.15.3",
"unplugin-vue-components": "^0.24.1",
"vite": "^4.3.8",
"typescript": "^5.1.3",
"unocss": "^0.53.1",
"unplugin-auto-import": "^0.16.4",
"unplugin-icons": "^0.16.3",
"unplugin-vue-components": "^0.25.1",
"vite": "^4.3.9",
"vite-plugin-compression": "^0.5.1",
"vite-plugin-mock": "^2.9.6",
"vite-plugin-svg-icons": "^2.0.1",
"vite-plugin-vue-devtools": "^0.2.0",
"vite-plugin-vue-setup-extend": "^0.4.0",
"vue-tsc": "^1.6.5"
},
@ -110,6 +110,7 @@
"eslint --fix"
],
"*.vue": [
"eslint --fix" ]
"eslint --fix"
]
}
}

View File

@ -19,5 +19,3 @@ const themeOverrides: GlobalThemeOverrides = {} || themeConfig
<naive-provider><router-view /></naive-provider>
</n-config-provider>
</template>
<style scoped></style>

View File

@ -1,6 +1,4 @@
import { defineConfig } from '@unocss/vite' // https://github.com/unocss/unocss
import presetUno from '@unocss/preset-uno'
import presetAttributify from '@unocss/preset-attributify'
import { presetUno,presetAttributify,defineConfig } from 'unocss' // https://github.com/unocss/unocss
export default defineConfig({
presets: [presetUno({ dark: 'class' }), presetAttributify()],