mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
docs: update document for “import on demand in vite projects” (#10158)
This commit is contained in:
parent
52e74a9cc4
commit
a092ee3ad6
@ -99,7 +99,14 @@ If you are using vite, please use [vite-plugin-style-import](https://github.com/
|
||||
#### 1. Install Plugin
|
||||
|
||||
```bash
|
||||
npm i vite-plugin-style-import@1.2.0 -D
|
||||
# with npm
|
||||
npm i vite-plugin-style-import -D
|
||||
|
||||
# with yarn
|
||||
yarn add vite-plugin-style-import -D
|
||||
|
||||
# with pnpm
|
||||
pnpm add vite-plugin-style-import -D
|
||||
```
|
||||
|
||||
#### 2. Configure Plugin
|
||||
@ -108,19 +115,13 @@ Configure the plugin in the `vite.config.js` file:
|
||||
|
||||
```js
|
||||
import vue from '@vitejs/plugin-vue';
|
||||
import styleImport from 'vite-plugin-style-import';
|
||||
import styleImport, { VantResolve } from 'vite-plugin-style-import';
|
||||
|
||||
export default {
|
||||
plugins: [
|
||||
vue(),
|
||||
styleImport({
|
||||
libs: [
|
||||
{
|
||||
libraryName: 'vant',
|
||||
esModule: true,
|
||||
resolveStyle: (name) => `vant/es/${name}/style/index`,
|
||||
},
|
||||
],
|
||||
resolves: [VantResolve()],
|
||||
}),
|
||||
],
|
||||
};
|
||||
|
@ -100,7 +100,14 @@ pnpm add vant@3
|
||||
#### 1. 安装插件
|
||||
|
||||
```bash
|
||||
npm i vite-plugin-style-import@1.2.0 -D
|
||||
# 通过 npm 安装
|
||||
npm i vite-plugin-style-import -D
|
||||
|
||||
# 通过 yarn 安装
|
||||
yarn add vite-plugin-style-import -D
|
||||
|
||||
# 通过 pnpm 安装
|
||||
pnpm add vite-plugin-style-import -D
|
||||
```
|
||||
|
||||
#### 2. 配置插件
|
||||
@ -109,19 +116,13 @@ npm i vite-plugin-style-import@1.2.0 -D
|
||||
|
||||
```js
|
||||
import vue from '@vitejs/plugin-vue';
|
||||
import styleImport from 'vite-plugin-style-import';
|
||||
import styleImport, { VantResolve } from 'vite-plugin-style-import';
|
||||
|
||||
export default {
|
||||
plugins: [
|
||||
vue(),
|
||||
styleImport({
|
||||
libs: [
|
||||
{
|
||||
libraryName: 'vant',
|
||||
esModule: true,
|
||||
resolveStyle: (name) => `vant/es/${name}/style/index`,
|
||||
},
|
||||
],
|
||||
resolves: [VantResolve()],
|
||||
}),
|
||||
],
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user