Skip to content

Commit

Permalink
build: 恢复 vitest, bundle-visualizer
Browse files Browse the repository at this point in the history
  • Loading branch information
FuckDoctors committed Aug 19, 2024
1 parent 8f88bcd commit eace5a0
Show file tree
Hide file tree
Showing 6 changed files with 392 additions and 176 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,6 @@ node_modules/
docs/.vuepress/.cache/
docs/.vuepress/.temp/
docs/.vuepress/dist/

# rollup-plugin-visualizer
/stats.html
14 changes: 14 additions & 0 deletions docs/.vuepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import { pwaPlugin } from '@vuepress/plugin-pwa'
import { sitemapPlugin } from '@vuepress/plugin-sitemap'

import { viteBundler } from '@vuepress/bundler-vite'
import type { PluginOption } from 'vite'
import { visualizer } from 'rollup-plugin-visualizer'

import { themeOptions } from './theme.js'
import themeZhaobc from './theme/index'
Expand All @@ -14,6 +16,8 @@ import { docsearch, pwa, seo } from './plugin-config'

const base = (process.env.BASE as '/' | `/${string}/`) || '/'

const sizeCheck = !!process.env.SIZE_CHECK

export default defineUserConfig({
theme: themeZhaobc(themeOptions),

Expand Down Expand Up @@ -91,6 +95,16 @@ export default defineUserConfig({

bundler: viteBundler({
viteOptions: {
plugins: [
sizeCheck
? (visualizer({
open: true,
title: 'Vite Bundle Visualizer',
brotliSize: true,
gzipSize: true,
}) as PluginOption)
: null,
],
ssr: {
noExternal: ['floating-vue'],
},
Expand Down
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"docs:clean-dev": "vuepress-vite dev docs --clean-cache",
"docs:dev": "vuepress-vite dev docs",
"docs:update": "pnpm dlx vp-update",
"sizecheck": "npx vite-bundle-visualizer"
"test": "vitest",
"sizecheck": "cross-env SIZE_CHECK=true pnpm docs:build"
},
"dependencies": {
"@shikijs/vitepress-twoslash": "^1.12.1",
Expand All @@ -47,7 +48,9 @@
"@textlint/types": "^14.0.4",
"@types/postcss-import": "^14.0.3",
"@unocss/eslint-config": "^0.58.9",
"@vitest/coverage-v8": "^2.0.5",
"@vue/repl": "^4.3.1",
"@vue/test-utils": "^2.4.6",
"@vuepress/bundler-vite": "2.0.0-rc.14",
"@vuepress/bundler-webpack": "2.0.0-rc.14",
"@vuepress/plugin-docsearch": "2.0.0-rc.37",
Expand Down Expand Up @@ -89,6 +92,7 @@
"remark-toc": "^9.0.0",
"remark-validate-links": "^13.0.1",
"reveal.js": "^5.1.0",
"rollup-plugin-visualizer": "^5.12.0",
"sandpack-vue3": "^3.1.11",
"sass": "^1.77.6",
"shikiji": "^0.10.2",
Expand All @@ -107,6 +111,7 @@
"textlint-rule-unexpanded-acronym": "^1.2.4",
"typescript": "^5.5.3",
"unocss": "^0.58.9",
"vitest": "^2.0.5",
"vue-tsc": "^1.8.27",
"vuepress": "2.0.0-rc.14",
"vuepress-theme-hope": "2.0.0-rc.50"
Expand Down
Loading

0 comments on commit eace5a0

Please sign in to comment.