vuepress 2.x 集成 element-plus
生活随笔
收集整理的這篇文章主要介紹了
vuepress 2.x 集成 element-plus
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
安裝element-plus
進入vuepress根目錄,執行命令
npm install element-plus修改 clientAppEnhance.js
接下來需要修改用于客戶端應用增強的docs/.vuepress/clientAppEnhance.js文件
vuepress的目錄結構如下:
修改后文件如下:
import * as Icons from '@element-plus/icons-vue' import { defineClientAppEnhance } from '@vuepress/client' import ElementPlus from 'element-plus' import 'element-plus/theme-chalk/index.css'export default defineClientAppEnhance(({ app }) => {app.use(ElementPlus)// iconfor (const icon in Icons) {// eslint-disable-next-line import/namespaceapp.component('ElIcon' + icon, Icons[icon])} })chainWebpack配置
參考:https://v2.vuepress.vuejs.org/reference/bundler/webpack.html#chainwebpack
vite配置
if (app.env.isDev && app.options.bundler.endsWith('vite')) {// eslint-disable-next-line import/no-extraneous-dependenciesapp.options.bundlerConfig.viteOptions = require('vite').mergeConfig(app.options.bundlerConfig.viteOptions,{optimizeDeps: {include: ['lodash'],},})}使用
接下來就可以像往常一樣食用element的組件了
<el-button type="success">按鈕</el-button>NPM
Install
npm i -D @starzkg/vuepress-plugin-element-plus或
yarn add -D @starzkg/vuepress-plugin-element-plus參考源碼
- https://github.com/vuejs/vue-cli/blob/next/packages/%40vue/cli-service/lib/config/base.js#L16-L21
Issue
- [Bug Report] 1.2.0-beta.1 cannot resolve lodash
- Struggling to use with WebPack5
參考文章
- vuepress集成element-ui
- webpack打包導入的文件時候省略后綴名設置
- npm:webpack-chain
總結
以上是生活随笔為你收集整理的vuepress 2.x 集成 element-plus的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 《移动项目实践》实验报告——Androi
- 下一篇: vuepress 2.x 集成百度统计