Skip to content

Commit 051c84a

Browse files
committed
docs: update content about import map prop
1 parent edabcb5 commit 051c84a

File tree

5 files changed

+41
-8
lines changed

5 files changed

+41
-8
lines changed

README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ interface Props {
4949
previewBodyStyle: Partial<CSSStyleDeclaration> | string
5050
// Styling of the root component in the iframe element
5151
previewAppStyle?: Partial<CSSStyleDeclaration> | string
52+
// Third-party dependencies (CDN) that can be introduced by the demo component
53+
importMap?: Record<string, string> | string
5254
}
5355
```
5456

@@ -78,7 +80,7 @@ interface Props {
7880
```TS
7981
import { createApp } from 'vue'
8082
import { VuePreview } from 'vite-plugin-vue-preview'
81-
import 'vite-plugin-vue-preview/dist/style.css'
83+
import 'vite-plugin-vue-preview/style.css'
8284

8385
const app = createApp()
8486

@@ -102,7 +104,7 @@ export default defineConfig({
102104
// .vitepress/theme/index.ts
103105
import DefaultTheme from 'vitepress/theme'
104106
import { VuePreview } from 'vite-plugin-vue-preview'
105-
import 'vite-plugin-vue-preview/dist/style.css'
107+
import 'vite-plugin-vue-preview/style.css'
106108

107109
export default {
108110
...DefaultTheme,
@@ -148,6 +150,9 @@ export default defineConfig({
148150
alignItems: 'center',
149151
flexDirection: 'column',
150152
},
153+
importMap: {
154+
'@vue/shared': 'https://unpkg.com/@vue/shared@latest/dist/shared.esm-bundler.js',
155+
},
151156
},
152157
})],
153158
})

README.zh-CN.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ interface Props {
4949
previewBodyStyle: Partial<CSSStyleDeclaration> | string
5050
// iframe 元素中根组件的样式
5151
previewAppStyle?: Partial<CSSStyleDeclaration> | string
52+
// demo 组件可引入的第三方依赖(CDN)
53+
importMap?: Record<string, string> | string
5254
}
5355
```
5456

@@ -78,7 +80,7 @@ interface Props {
7880
```TS
7981
import { createApp } from 'vue'
8082
import { VuePreview } from 'vite-plugin-vue-preview'
81-
import 'vite-plugin-vue-preview/dist/style.css'
83+
import 'vite-plugin-vue-preview/style.css'
8284

8385
const app = createApp()
8486

@@ -101,7 +103,7 @@ export default defineConfig({
101103
// .vitepress/theme/index.ts
102104
import DefaultTheme from 'vitepress/theme'
103105
import { VuePreview } from 'vite-plugin-vue-preview'
104-
import 'vite-plugin-vue-preview/dist/style.css'
106+
import 'vite-plugin-vue-preview/style.css'
105107

106108
export default {
107109
...DefaultTheme,
@@ -147,6 +149,9 @@ export default defineConfig({
147149
alignItems: 'center',
148150
flexDirection: 'column',
149151
},
152+
importMap: {
153+
'@vue/shared': 'https://unpkg.com/@vue/shared@latest/dist/shared.esm-bundler.js',
154+
},
150155
},
151156
})],
152157
})

test/vitepress/index.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,13 @@ A Vite plugin made for previewing and editing Vue components in Markdown and, of
1313

1414
<!-- #region demo -->
1515
```vue preview
16+
<script lang="ts" setup>
17+
import { isSpecialBooleanAttr } from '@vue/shared'
18+
</script>
19+
1620
<template>
1721
<h1>Demo: vite-plugin-vue-preview</h1>
22+
<span>readonly is special boolean attr: {{ isSpecialBooleanAttr('readonly') }}</span>
1823
</template>
1924
```
2025
<!-- #endregion demo -->
@@ -49,6 +54,8 @@ interface Props {
4954
previewBodyStyle: Partial<CSSStyleDeclaration> | string
5055
// Styling of the root component in the iframe element
5156
previewAppStyle?: Partial<CSSStyleDeclaration> | string
57+
// Third-party dependencies (CDN) that can be introduced by the demo component
58+
importMap?: Record<string, string> | string
5259
}
5360
```
5461

@@ -78,7 +85,7 @@ interface Props {
7885
```TS
7986
import { createApp } from 'vue'
8087
import { VuePreview } from 'vite-plugin-vue-preview'
81-
import 'vite-plugin-vue-preview/dist/style.css'
88+
import 'vite-plugin-vue-preview/style.css'
8289

8390
const app = createApp()
8491

@@ -102,7 +109,7 @@ export default defineConfig({
102109
// .vitepress/theme/index.ts
103110
import DefaultTheme from 'vitepress/theme'
104111
import { VuePreview } from 'vite-plugin-vue-preview'
105-
import 'vite-plugin-vue-preview/dist/style.css'
112+
import 'vite-plugin-vue-preview/style.css'
106113

107114
export default {
108115
...DefaultTheme,
@@ -140,6 +147,9 @@ export default defineConfig({
140147
alignItems: 'center',
141148
flexDirection: 'column',
142149
},
150+
importMap: {
151+
'@vue/shared': 'https://unpkg.com/@vue/shared@latest/dist/shared.esm-bundler.js',
152+
},
143153
},
144154
})],
145155
})

test/vitepress/vite.config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ export default defineConfig({
1515
alignItems: 'center',
1616
flexDirection: 'column',
1717
},
18+
importMap: {
19+
'@vue/shared': 'https://unpkg.com/@vue/shared@latest/dist/shared.esm-bundler.js',
20+
},
1821
},
1922
})],
2023
})

test/vitepress/zh/index.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,13 @@
1313

1414
<!-- #region demo -->
1515
```vue preview
16+
<script lang="ts" setup>
17+
import { isSpecialBooleanAttr } from '@vue/shared'
18+
</script>
19+
1620
<template>
1721
<h1>演示: vite-plugin-vue-preview</h1>
22+
<span>readonly is special boolean attr: {{ isSpecialBooleanAttr('readonly') }}</span>
1823
</template>
1924
```
2025
<!-- #endregion demo -->
@@ -49,6 +54,8 @@ interface Props {
4954
previewBodyStyle: Partial<CSSStyleDeclaration> | string
5055
// iframe 元素中根组件的样式
5156
previewAppStyle?: Partial<CSSStyleDeclaration> | string
57+
// demo 组件可引入的第三方依赖(CDN)
58+
importMap?: Record<string, string> | string
5259
}
5360
```
5461

@@ -78,7 +85,7 @@ interface Props {
7885
```TS
7986
import { createApp } from 'vue'
8087
import { VuePreview } from 'vite-plugin-vue-preview'
81-
import 'vite-plugin-vue-preview/dist/style.css'
88+
import 'vite-plugin-vue-preview/style.css'
8289

8390
const app = createApp()
8491

@@ -101,7 +108,7 @@ export default defineConfig({
101108
// .vitepress/theme/index.ts
102109
import DefaultTheme from 'vitepress/theme'
103110
import { VuePreview } from 'vite-plugin-vue-preview'
104-
import 'vite-plugin-vue-preview/dist/style.css'
111+
import 'vite-plugin-vue-preview/style.css'
105112

106113
export default {
107114
...DefaultTheme,
@@ -139,6 +146,9 @@ export default defineConfig({
139146
alignItems: 'center',
140147
flexDirection: 'column',
141148
},
149+
importMap: {
150+
'@vue/shared': 'https://unpkg.com/@vue/shared@latest/dist/shared.esm-bundler.js',
151+
},
142152
},
143153
})],
144154
})

0 commit comments

Comments
 (0)