perf: 优化启动速度
This commit is contained in:
parent
3a5db42c97
commit
379b340750
|
@ -1,5 +1,5 @@
|
||||||
# 环境
|
# 环境
|
||||||
NODE_ENV=development
|
VITE_NODE_ENV=development
|
||||||
|
|
||||||
# 接口前缀
|
# 接口前缀
|
||||||
VITE_API_BASE_PATH=
|
VITE_API_BASE_PATH=
|
||||||
|
@ -9,3 +9,6 @@ VITE_BASE_PATH=/
|
||||||
|
|
||||||
# 标题
|
# 标题
|
||||||
VITE_APP_TITLE=ElementAdmin
|
VITE_APP_TITLE=ElementAdmin
|
||||||
|
|
||||||
|
# 是否全量引入element-plus样式
|
||||||
|
VITE_USE_ALL_ELEMENT_PLUS_STYLE=true
|
||||||
|
|
5
.env.dev
5
.env.dev
|
@ -1,5 +1,5 @@
|
||||||
# 环境
|
# 环境
|
||||||
NODE_ENV=production
|
VITE_NODE_ENV=production
|
||||||
|
|
||||||
# 接口前缀
|
# 接口前缀
|
||||||
VITE_API_BASE_PATH=
|
VITE_API_BASE_PATH=
|
||||||
|
@ -24,3 +24,6 @@ VITE_APP_TITLE=ElementAdmin
|
||||||
|
|
||||||
# 是否包分析
|
# 是否包分析
|
||||||
VITE_USE_BUNDLE_ANALYZER=false
|
VITE_USE_BUNDLE_ANALYZER=false
|
||||||
|
|
||||||
|
# 是否全量引入element-plus样式
|
||||||
|
VITE_USE_ALL_ELEMENT_PLUS_STYLE=false
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# 环境
|
# 环境
|
||||||
NODE_ENV=production
|
VITE_NODE_ENV=production
|
||||||
|
|
||||||
# 接口前缀
|
# 接口前缀
|
||||||
VITE_API_BASE_PATH=
|
VITE_API_BASE_PATH=
|
||||||
|
@ -24,3 +24,6 @@ VITE_APP_TITLE=ElementAdmin
|
||||||
|
|
||||||
# 是否包分析
|
# 是否包分析
|
||||||
VITE_USE_BUNDLE_ANALYZER=false
|
VITE_USE_BUNDLE_ANALYZER=false
|
||||||
|
|
||||||
|
# 是否全量引入element-plus样式
|
||||||
|
VITE_USE_ALL_ELEMENT_PLUS_STYLE=false
|
5
.env.pro
5
.env.pro
|
@ -1,5 +1,5 @@
|
||||||
# 环境
|
# 环境
|
||||||
NODE_ENV=production
|
VITE_NODE_ENV=production
|
||||||
|
|
||||||
# 接口前缀
|
# 接口前缀
|
||||||
VITE_API_BASE_PATH=
|
VITE_API_BASE_PATH=
|
||||||
|
@ -24,3 +24,6 @@ VITE_APP_TITLE=ElementAdmin
|
||||||
|
|
||||||
# 是否包分析
|
# 是否包分析
|
||||||
VITE_USE_BUNDLE_ANALYZER=true
|
VITE_USE_BUNDLE_ANALYZER=true
|
||||||
|
|
||||||
|
# 是否全量引入element-plus样式
|
||||||
|
VITE_USE_ALL_ELEMENT_PLUS_STYLE=false
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# 环境
|
# 环境
|
||||||
NODE_ENV=production
|
VITE_NODE_ENV=production
|
||||||
|
|
||||||
# 接口前缀
|
# 接口前缀
|
||||||
VITE_API_BASE_PATH=
|
VITE_API_BASE_PATH=
|
||||||
|
@ -24,3 +24,6 @@ VITE_APP_TITLE=ElementAdmin
|
||||||
|
|
||||||
# 是否包分析
|
# 是否包分析
|
||||||
VITE_USE_BUNDLE_ANALYZER=false
|
VITE_USE_BUNDLE_ANALYZER=false
|
||||||
|
|
||||||
|
# 是否全量引入element-plus样式
|
||||||
|
VITE_USE_ALL_ELEMENT_PLUS_STYLE=false
|
||||||
|
|
|
@ -4,6 +4,7 @@ import { useAppStore } from '@/store/modules/app'
|
||||||
import { ConfigGlobal } from '@/components/ConfigGlobal'
|
import { ConfigGlobal } from '@/components/ConfigGlobal'
|
||||||
import { useDesign } from '@/hooks/web/useDesign'
|
import { useDesign } from '@/hooks/web/useDesign'
|
||||||
import { useDark } from '@vueuse/core'
|
import { useDark } from '@vueuse/core'
|
||||||
|
// import { ElNotification } from 'element-plus'
|
||||||
|
|
||||||
const { getPrefixCls } = useDesign()
|
const { getPrefixCls } = useDesign()
|
||||||
|
|
||||||
|
@ -21,6 +22,14 @@ const isDark = useDark({
|
||||||
})
|
})
|
||||||
|
|
||||||
isDark.value = appStore.getIsDark
|
isDark.value = appStore.getIsDark
|
||||||
|
// ElNotification({
|
||||||
|
// title: '提示',
|
||||||
|
// type: 'warning',
|
||||||
|
// duration: 0,
|
||||||
|
// dangerouslyUseHTMLString: true,
|
||||||
|
// message:
|
||||||
|
// '<div><p><strong>遇事不决,请先查阅常见问题,说不定你能找到相关解答</strong></p><p><a href="https://www.baidu.com" target="_blank">链接地址</a></p></div>'
|
||||||
|
// })
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|
|
@ -12,6 +12,12 @@ export const setupElementPlus = (app: App<Element>) => {
|
||||||
app.use(plugin)
|
app.use(plugin)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// 为了开发环境启动更快,一次性引入所有样式
|
||||||
|
if (import.meta.env.VITE_USE_ALL_ELEMENT_PLUS_STYLE === 'true') {
|
||||||
|
import('element-plus/dist/index.css')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
components.forEach((component) => {
|
components.forEach((component) => {
|
||||||
app.component(component.name!, component)
|
app.component(component.name!, component)
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,3 +1 @@
|
||||||
import 'virtual:svg-icons-register'
|
import 'virtual:svg-icons-register'
|
||||||
|
|
||||||
import '@purge-icons/generated'
|
|
||||||
|
|
|
@ -20,12 +20,8 @@ module.exports = {
|
||||||
'function-no-unknown': null,
|
'function-no-unknown': null,
|
||||||
'no-empty-source': null,
|
'no-empty-source': null,
|
||||||
'named-grid-areas-no-invalid': null,
|
'named-grid-areas-no-invalid': null,
|
||||||
'unicode-bom': 'never',
|
|
||||||
'no-descending-specificity': null,
|
'no-descending-specificity': null,
|
||||||
'font-family-no-missing-generic-family-keyword': null,
|
'font-family-no-missing-generic-family-keyword': null,
|
||||||
'declaration-colon-space-after': 'always-single-line',
|
|
||||||
'declaration-colon-space-before': 'never',
|
|
||||||
'declaration-block-trailing-semicolon': null,
|
|
||||||
'rule-empty-line-before': [
|
'rule-empty-line-before': [
|
||||||
'always',
|
'always',
|
||||||
{
|
{
|
||||||
|
|
|
@ -40,7 +40,8 @@ export default ({ command, mode }: ConfigEnv): UserConfig => {
|
||||||
}),
|
}),
|
||||||
VueJsx(),
|
VueJsx(),
|
||||||
progress(),
|
progress(),
|
||||||
createStyleImportPlugin({
|
env.VITE_USE_ALL_ELEMENT_PLUS_STYLE === 'false'
|
||||||
|
? createStyleImportPlugin({
|
||||||
resolves: [ElementPlusResolve()],
|
resolves: [ElementPlusResolve()],
|
||||||
libs: [
|
libs: [
|
||||||
{
|
{
|
||||||
|
@ -54,7 +55,8 @@ export default ({ command, mode }: ConfigEnv): UserConfig => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}),
|
})
|
||||||
|
: undefined,
|
||||||
EslintPlugin({
|
EslintPlugin({
|
||||||
cache: false,
|
cache: false,
|
||||||
include: ['src/**/*.vue', 'src/**/*.ts', 'src/**/*.tsx'] // 检查的文件
|
include: ['src/**/*.vue', 'src/**/*.ts', 'src/**/*.tsx'] // 检查的文件
|
||||||
|
@ -120,7 +122,16 @@ export default ({ command, mode }: ConfigEnv): UserConfig => {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
rollupOptions: {
|
rollupOptions: {
|
||||||
plugins: env.VITE_USE_BUNDLE_ANALYZER === 'true' ? [visualizer()] : undefined
|
plugins: env.VITE_USE_BUNDLE_ANALYZER === 'true' ? [visualizer()] : undefined,
|
||||||
|
// 拆包
|
||||||
|
output: {
|
||||||
|
manualChunks: {
|
||||||
|
vue: ['vue', 'vue-router', 'pinia', 'vue-i18n'],
|
||||||
|
'element-plus': ['element-plus'],
|
||||||
|
'wang-editor': ['@wangeditor/editor', '@wangeditor/editor-for-vue'],
|
||||||
|
echarts: ['echarts', 'echarts-wordcloud']
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
server: {
|
server: {
|
||||||
|
|
Loading…
Reference in New Issue