From 9fcde5bd02f9e6a675efe46e51a51f9f99b082d9 Mon Sep 17 00:00:00 2001 From: "@andatoshiki" Date: Sun, 17 Sep 2023 02:10:43 -0700 Subject: [PATCH] chore: update vite webpack config with new plugin and page behavior parameters implemented --- docs/vite.config.ts | 80 ++++++++++++++++++++++++++++++--------------- 1 file changed, 53 insertions(+), 27 deletions(-) diff --git a/docs/vite.config.ts b/docs/vite.config.ts index e0df6fde..e544efff 100644 --- a/docs/vite.config.ts +++ b/docs/vite.config.ts @@ -4,37 +4,63 @@ import UnoCSS from 'unocss/vite' import { MarkdownTransform } from './.vitepress/plugins/markdownTransform' import Icons from 'unplugin-icons/vite' import IconsResolver from 'unplugin-icons/resolver' +import { ArcoResolver } from 'unplugin-vue-components/resolvers' +import { resolve } from 'node:path' +import { createRequire } from 'node:module' +import type { UserConfig } from 'vite' -export default defineConfig({ - plugins: [ - Components({ - dirs: ['.vitepress/theme/components'], - include: [/\.vue$/, /\.vue\?vue/, /\.md$/], - resolvers: [ - IconsResolver({ - componentPrefix: '', - }), - ], - dts: './.vitepress/components.d.ts', - transformer: 'vue3', - }), - Icons({ - compiler: 'vue3', - autoInstall: true, - defaultStyle: 'display: inline-block', - }), - UnoCSS(), - MarkdownTransform(), - ], +const require = createRequire(import.meta.url) + +export default defineConfig(async () => { + return { + server: { + hmr: { + overlay: false, + }, + fs: { + allow: [resolve(__dirname, '..')], + }, + }, + plugins: [ + // custom markdown transformation plugin with regex + MarkdownTransform(), + // custom components including plugins + Components({ + dirs: ['.vitepress/theme/components'], + include: [/\.vue$/, /\.vue\?vue/, /\.md$/], + resolvers: [ + IconsResolver({ + componentPrefix: '', + }), + ArcoResolver({ sideEffect: true, resolveIcons: true }), + ], + dts: './.vitepress/components.d.ts', + transformer: 'vue3', + }), + Icons({ + compiler: 'vue3', + autoInstall: true, + defaultStyle: 'display: inline-block', + }), + UnoCSS(), + ], css: { postcss: { plugins: [require('postcss-nested')], }, }, - ssr: { - noExternal: ['@andatoshiki/vitepress-plugin-nprogress', '@arco-design/web-vue'], - }, - build: { - chunkSizeWarningLimit: 1600, - }, + ssr: { + noExternal: ['@andatoshiki/vitepress-plugin-nprogress', '@arco-design/web-vue'], + }, + build: { + chunkSizeWarningLimit: 1600, + // rollup build options + rollupOptions: { + external: [ + 'node:*', + './assets/*', + ], + }, + }, + } })