Skip to content

Commit

Permalink
feat:添加 打包体积分析 and 统一函数书写方式 (Evansy#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
AuYuHui authored Jun 5, 2023
1 parent 5c8e3fd commit 3e8c6f2
Show file tree
Hide file tree
Showing 6 changed files with 190 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ dist
dist-ssr
coverage
*.local
report.html

/cypress/videos/
/cypress/screenshots/
Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"dev": "vite --host",
"build": "run-p type-check build-only",
"preview": "vite preview",
"build-only": "vite build",
"report": "rimraf dist && vite build",
"build-only": "rimraf dist && vite build",
"type-check": "vue-tsc --noEmit",
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore",
"link:format": "prettier --write src/",
Expand Down Expand Up @@ -54,6 +55,8 @@
"postcss-html": "^1.5.0",
"postcss-scss": "^4.0.6",
"prettier": "^2.8.8",
"rimraf": "^5.0.1",
"rollup-plugin-visualizer": "^5.9.0",
"sass": "^1.62.1",
"stylelint": "^15.6.3",
"stylelint-config-prettier": "^9.0.5",
Expand Down
178 changes: 178 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/utils/copy.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export function copyToClip(text: string) {
export const copyToClip = (text: string) => {
return new Promise((resolve, reject) => {
try {
const input: HTMLTextAreaElement = document.createElement('textarea')
Expand Down
2 changes: 1 addition & 1 deletion src/views/Home/components/ChatList/MsgItem/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ const scrollToMsg = async (msg: MessageItemContentType) => {
}
/** 右键菜单 */
function handleRightClick(e: MouseEvent, msg: MessageItemType) {
const handleRightClick = (e: MouseEvent, msg: MessageItemType) => {
ContextMenu.showContextMenu({
theme: 'mac dark',
items: [
Expand Down
5 changes: 5 additions & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@ import IconsResolver from 'unplugin-icons/resolver'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
import { visualizer } from 'rollup-plugin-visualizer'

const pathSrc = path.resolve(__dirname, 'src')

const lifecycle = process.env.npm_lifecycle_event

// https://vitejs.dev/config/
export default defineConfig({
plugins: [
Expand All @@ -36,6 +39,8 @@ export default defineConfig({
dts: path.resolve(pathSrc, 'components.d.ts'),
}),
Icons({ autoInstall: true }),
// 打包分析
lifecycle === 'report' ? visualizer({ open: true, brotliSize: true, filename: 'report.html' }) : null,
],
resolve: {
alias: {
Expand Down

0 comments on commit 3e8c6f2

Please sign in to comment.