docs: update document for “import on demand in vite projects” (#10158)

This commit is contained in:
aisen60 2022-01-06 19:01:50 +08:00 committed by GitHub
parent 52e74a9cc4
commit a092ee3ad6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 18 deletions

View File

@ -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()],
}),
],
};

View File

@ -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()],
}),
],
};