vite-plugin-storybook-nextjs 3.0.3--canary.68.b6ee25e.0 → 3.0.4--canary.5f06d44.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +43 -2
- package/dist/index.cjs +1633 -20
- package/dist/index.d.cts +14 -3
- package/dist/index.d.ts +14 -3
- package/dist/index.js +1633 -20
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -62,15 +62,56 @@ export default defineConfig({
|
|
|
62
62
|
You can configure the plugin using the following options:
|
|
63
63
|
|
|
64
64
|
```ts
|
|
65
|
+
type FilterPattern = ReadonlyArray<string | RegExp> | string | RegExp | null
|
|
66
|
+
|
|
65
67
|
type VitePluginOptions = {
|
|
66
68
|
/**
|
|
67
69
|
* Provide the path to your Next.js project directory
|
|
68
70
|
* @default process.cwd()
|
|
69
71
|
*/
|
|
70
|
-
dir?: string
|
|
71
|
-
|
|
72
|
+
dir?: string
|
|
73
|
+
/**
|
|
74
|
+
* Control which image files are handled by the Next Image plugin
|
|
75
|
+
* (Rollup-style include/exclude patterns)
|
|
76
|
+
*/
|
|
77
|
+
image?: {
|
|
78
|
+
include?: FilterPattern
|
|
79
|
+
exclude?: FilterPattern
|
|
80
|
+
}
|
|
81
|
+
}
|
|
72
82
|
```
|
|
73
83
|
|
|
84
|
+
### FAQ: Including/Excluding images
|
|
85
|
+
|
|
86
|
+
When you also use the SVG-to-React plugin [vite-plugin-svgr](https://github.com/pd4d10/vite-plugin-svgr), you may want SVGs imported with the `?react` query to be handled by SVGR, while all other images (including plain SVGs) are handled by this plugin's Next Image processing.
|
|
87
|
+
|
|
88
|
+
You can achieve this by excluding `**/*.svg?react` from the Next Image handling and (optionally) narrowing what it includes. The patterns follow Rollup's FilterPattern semantics.
|
|
89
|
+
|
|
90
|
+
```ts
|
|
91
|
+
// vite.config.ts or vitest.config.ts
|
|
92
|
+
import { defineConfig } from 'vite'
|
|
93
|
+
import nextjs from 'vite-plugin-storybook-nextjs'
|
|
94
|
+
import svgr from 'vite-plugin-svgr'
|
|
95
|
+
|
|
96
|
+
export default defineConfig({
|
|
97
|
+
plugins: [
|
|
98
|
+
svgr({ include: '**/*.svg?react' }),
|
|
99
|
+
nextjs({
|
|
100
|
+
image: {
|
|
101
|
+
// Default image glob patterns are already applied; this is optional
|
|
102
|
+
// include: ['**/*.{png,jpg,jpeg,gif,webp,avif,ico,bmp,svg}'],
|
|
103
|
+
// Ensure SVGR takes precedence for React components from SVGs
|
|
104
|
+
exclude: ['**/*.svg?react'],
|
|
105
|
+
},
|
|
106
|
+
}),
|
|
107
|
+
],
|
|
108
|
+
})
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
Notes:
|
|
112
|
+
- If you do not customize `image.include`, the plugin defaults to common image extensions.
|
|
113
|
+
- Excluding `**/*.svg?react` prevents collisions so that `import Icon from "./icon.svg?react"` is compiled by SVGR, while `import iconUrl from "./icon.svg"` is handled by Next Image.
|
|
114
|
+
|
|
74
115
|
## Usage with portable stories
|
|
75
116
|
|
|
76
117
|
[Portable stories](https://storybook.js.org/docs/api/portable-stories/portable-stories-vitest) are Storybook stories which can be used in external environments, such as Vitest.
|