@biggora/claude-plugins 1.1.1 → 1.2.2

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.
Files changed (104) hide show
  1. package/.claude/settings.local.json +3 -1
  2. package/README.md +24 -17
  3. package/package.json +1 -1
  4. package/registry/registry.json +319 -244
  5. package/specs/coding.md +24 -0
  6. package/specs/pod.md +2 -0
  7. package/src/skills/captcha/README.md +221 -0
  8. package/src/skills/captcha/SKILL.md +355 -0
  9. package/src/skills/captcha/references/captcha-types.md +254 -0
  10. package/src/skills/captcha/references/services.md +172 -0
  11. package/src/skills/captcha/references/stealth.md +238 -0
  12. package/src/skills/captcha/scripts/solve_captcha.py +323 -0
  13. package/src/skills/captcha/scripts/solve_image_grid.py +350 -0
  14. package/src/skills/codex-cli/SKILL.md +21 -11
  15. package/src/skills/gemini-cli/SKILL.md +27 -13
  16. package/src/skills/gemini-cli/references/commands.md +21 -14
  17. package/src/skills/gemini-cli/references/configuration.md +23 -18
  18. package/src/skills/gemini-cli/references/headless-and-scripting.md +7 -17
  19. package/src/skills/gemini-cli/references/mcp-and-extensions.md +12 -6
  20. package/src/skills/google-merchant-api/SKILL.md +581 -0
  21. package/src/skills/google-merchant-api/references/accounts.md +247 -0
  22. package/src/skills/google-merchant-api/references/content-api-legacy.md +216 -0
  23. package/src/skills/google-merchant-api/references/datasources.md +233 -0
  24. package/src/skills/google-merchant-api/references/inventories.md +201 -0
  25. package/src/skills/google-merchant-api/references/migration.md +267 -0
  26. package/src/skills/google-merchant-api/references/products.md +316 -0
  27. package/src/skills/google-merchant-api/references/promotions.md +201 -0
  28. package/src/skills/google-merchant-api/references/reports.md +240 -0
  29. package/src/skills/lv-aggregators-api/SKILL.md +113 -0
  30. package/src/skills/lv-aggregators-api/references/integration-guide.md +368 -0
  31. package/src/skills/lv-aggregators-api/references/kurpirkt.md +103 -0
  32. package/src/skills/lv-aggregators-api/references/salidzini.md +122 -0
  33. package/src/skills/notebook-lm/SKILL.md +1 -1
  34. package/src/skills/screen-recording/SKILL.md +243 -213
  35. package/src/skills/screen-recording/references/design-patterns.md +4 -2
  36. package/src/skills/screen-recording/references/ffmpeg-recording.md +473 -0
  37. package/src/skills/screen-recording/references/{approach1-programmatic.md → programmatic-generation.md} +45 -22
  38. package/src/skills/screen-recording/references/python-fallback.md +222 -0
  39. package/src/skills/tailwindcss-best-practices/SKILL.md +180 -0
  40. package/src/skills/tailwindcss-best-practices/references/best-practices-utility-patterns.md +87 -0
  41. package/src/skills/tailwindcss-best-practices/references/core-installation.md +109 -0
  42. package/src/skills/tailwindcss-best-practices/references/core-preflight.md +200 -0
  43. package/src/skills/tailwindcss-best-practices/references/core-responsive.md +163 -0
  44. package/src/skills/tailwindcss-best-practices/references/core-source-detection.md +114 -0
  45. package/src/skills/tailwindcss-best-practices/references/core-theme.md +108 -0
  46. package/src/skills/tailwindcss-best-practices/references/core-utility-classes.md +59 -0
  47. package/src/skills/tailwindcss-best-practices/references/core-variants.md +204 -0
  48. package/src/skills/tailwindcss-best-practices/references/effects-form-controls.md +76 -0
  49. package/src/skills/tailwindcss-best-practices/references/effects-mask.md +91 -0
  50. package/src/skills/tailwindcss-best-practices/references/effects-scroll-snap.md +59 -0
  51. package/src/skills/tailwindcss-best-practices/references/effects-text-shadow.md +78 -0
  52. package/src/skills/tailwindcss-best-practices/references/effects-transition-animation.md +80 -0
  53. package/src/skills/tailwindcss-best-practices/references/effects-visibility-interactivity.md +82 -0
  54. package/src/skills/tailwindcss-best-practices/references/features-content-detection.md +175 -0
  55. package/src/skills/tailwindcss-best-practices/references/features-custom-styles.md +203 -0
  56. package/src/skills/tailwindcss-best-practices/references/features-dark-mode.md +137 -0
  57. package/src/skills/tailwindcss-best-practices/references/features-functions-directives.md +241 -0
  58. package/src/skills/tailwindcss-best-practices/references/features-upgrade.md +160 -0
  59. package/src/skills/tailwindcss-best-practices/references/layout-aspect-ratio.md +39 -0
  60. package/src/skills/tailwindcss-best-practices/references/layout-columns.md +80 -0
  61. package/src/skills/tailwindcss-best-practices/references/layout-display.md +110 -0
  62. package/src/skills/tailwindcss-best-practices/references/layout-flexbox.md +112 -0
  63. package/src/skills/tailwindcss-best-practices/references/layout-grid.md +87 -0
  64. package/src/skills/tailwindcss-best-practices/references/layout-height.md +97 -0
  65. package/src/skills/tailwindcss-best-practices/references/layout-inset.md +103 -0
  66. package/src/skills/tailwindcss-best-practices/references/layout-logical-properties.md +92 -0
  67. package/src/skills/tailwindcss-best-practices/references/layout-margin.md +126 -0
  68. package/src/skills/tailwindcss-best-practices/references/layout-min-max-sizing.md +63 -0
  69. package/src/skills/tailwindcss-best-practices/references/layout-object-fit-position.md +64 -0
  70. package/src/skills/tailwindcss-best-practices/references/layout-overflow.md +57 -0
  71. package/src/skills/tailwindcss-best-practices/references/layout-padding.md +77 -0
  72. package/src/skills/tailwindcss-best-practices/references/layout-position.md +85 -0
  73. package/src/skills/tailwindcss-best-practices/references/layout-tables.md +67 -0
  74. package/src/skills/tailwindcss-best-practices/references/layout-width.md +102 -0
  75. package/src/skills/tailwindcss-best-practices/references/transform-base.md +68 -0
  76. package/src/skills/tailwindcss-best-practices/references/transform-rotate.md +70 -0
  77. package/src/skills/tailwindcss-best-practices/references/transform-scale.md +83 -0
  78. package/src/skills/tailwindcss-best-practices/references/transform-skew.md +62 -0
  79. package/src/skills/tailwindcss-best-practices/references/transform-translate.md +77 -0
  80. package/src/skills/tailwindcss-best-practices/references/typography-font-text.md +142 -0
  81. package/src/skills/tailwindcss-best-practices/references/typography-list-style.md +65 -0
  82. package/src/skills/tailwindcss-best-practices/references/typography-text-align.md +60 -0
  83. package/src/skills/tailwindcss-best-practices/references/visual-background.md +76 -0
  84. package/src/skills/tailwindcss-best-practices/references/visual-border.md +108 -0
  85. package/src/skills/tailwindcss-best-practices/references/visual-effects.md +111 -0
  86. package/src/skills/tailwindcss-best-practices/references/visual-svg.md +82 -0
  87. package/src/skills/test-mobile-app/SKILL.md +11 -6
  88. package/src/skills/test-mobile-app/scripts/analyze_apk.py +15 -4
  89. package/src/skills/test-mobile-app/scripts/check_environment.py +5 -5
  90. package/src/skills/test-mobile-app/scripts/run_tests.py +1 -1
  91. package/src/skills/test-web-ui/SKILL.md +264 -84
  92. package/src/skills/test-web-ui/scripts/discover.py +25 -12
  93. package/src/skills/test-web-ui/scripts/run_tests.py +3 -2
  94. package/src/skills/tm-search/SKILL.md +242 -106
  95. package/src/skills/tm-search/references/scraping-fallback.md +60 -95
  96. package/src/skills/tm-search/scripts/tm_search.py +453 -375
  97. package/src/skills/vite-best-practices/SKILL.md +115 -0
  98. package/src/skills/vite-best-practices/references/build-and-ssr.md +255 -0
  99. package/src/skills/vite-best-practices/references/core-config.md +231 -0
  100. package/src/skills/vite-best-practices/references/core-features.md +222 -0
  101. package/src/skills/vite-best-practices/references/core-plugin-api.md +294 -0
  102. package/src/skills/vite-best-practices/references/environment-api.md +108 -0
  103. package/src/skills/vite-best-practices/references/rolldown-migration.md +242 -0
  104. package/src/skills/screen-recording/references/approach2-xvfb.md +0 -232
@@ -0,0 +1,222 @@
1
+ ---
2
+ name: vite-features
3
+ description: Vite-specific import patterns and runtime features
4
+ ---
5
+
6
+ # Vite Features
7
+
8
+ ## Glob Import
9
+
10
+ Import multiple modules matching a pattern:
11
+
12
+ ```ts
13
+ const modules = import.meta.glob('./dir/*.ts')
14
+ // { './dir/foo.ts': () => import('./dir/foo.ts'), ... }
15
+
16
+ for (const path in modules) {
17
+ modules[path]().then((mod) => {
18
+ console.log(path, mod)
19
+ })
20
+ }
21
+ ```
22
+
23
+ ### Eager Loading
24
+
25
+ ```ts
26
+ const modules = import.meta.glob('./dir/*.ts', { eager: true })
27
+ // Modules loaded immediately, no dynamic import
28
+ ```
29
+
30
+ ### Named Imports
31
+
32
+ ```ts
33
+ const modules = import.meta.glob('./dir/*.ts', { import: 'setup' })
34
+ // Only imports the 'setup' export from each module
35
+
36
+ const defaults = import.meta.glob('./dir/*.ts', { import: 'default', eager: true })
37
+ ```
38
+
39
+ ### Multiple Patterns
40
+
41
+ ```ts
42
+ const modules = import.meta.glob(['./dir/*.ts', './another/*.ts'])
43
+ ```
44
+
45
+ ### Negative Patterns
46
+
47
+ ```ts
48
+ const modules = import.meta.glob(['./dir/*.ts', '!**/ignored.ts'])
49
+ ```
50
+
51
+ ### Custom Queries
52
+
53
+ ```ts
54
+ const svgRaw = import.meta.glob('./icons/*.svg', { query: '?raw', import: 'default' })
55
+ const svgUrls = import.meta.glob('./icons/*.svg', { query: '?url', import: 'default' })
56
+ ```
57
+
58
+ ## Asset Import Queries
59
+
60
+ ### URL Import
61
+
62
+ ```ts
63
+ import imgUrl from './img.png'
64
+ // Returns resolved URL: '/src/img.png' (dev) or '/assets/img.2d8efhg.png' (build)
65
+ ```
66
+
67
+ ### Explicit URL
68
+
69
+ ```ts
70
+ import workletUrl from './worklet.js?url'
71
+ ```
72
+
73
+ ### Raw String
74
+
75
+ ```ts
76
+ import shaderCode from './shader.glsl?raw'
77
+ ```
78
+
79
+ ### Inline/No-Inline
80
+
81
+ ```ts
82
+ import inlined from './small.png?inline' // Force base64 inline
83
+ import notInlined from './large.png?no-inline' // Force separate file
84
+ ```
85
+
86
+ ### Web Workers
87
+
88
+ ```ts
89
+ import Worker from './worker.ts?worker'
90
+ const worker = new Worker()
91
+
92
+ // Or inline:
93
+ import InlineWorker from './worker.ts?worker&inline'
94
+ ```
95
+
96
+ Preferred pattern using constructor:
97
+
98
+ ```ts
99
+ const worker = new Worker(new URL('./worker.ts', import.meta.url), {
100
+ type: 'module',
101
+ })
102
+ ```
103
+
104
+ ### WebAssembly (Vite 8: works in SSR too)
105
+
106
+ ```ts
107
+ import init from './module.wasm?init'
108
+ const instance = await init()
109
+ ```
110
+
111
+ ## Environment Variables
112
+
113
+ ### Built-in Constants
114
+
115
+ ```ts
116
+ import.meta.env.MODE // 'development' | 'production' | custom
117
+ import.meta.env.BASE_URL // Base URL from config
118
+ import.meta.env.PROD // true in production
119
+ import.meta.env.DEV // true in development
120
+ import.meta.env.SSR // true when running in server
121
+ ```
122
+
123
+ ### Custom Variables
124
+
125
+ Only `VITE_` prefixed vars exposed to client:
126
+
127
+ ```
128
+ # .env
129
+ VITE_API_URL=https://api.example.com
130
+ DB_PASSWORD=secret # NOT exposed to client
131
+ ```
132
+
133
+ ```ts
134
+ console.log(import.meta.env.VITE_API_URL) // works
135
+ console.log(import.meta.env.DB_PASSWORD) // undefined
136
+ ```
137
+
138
+ ### Mode-specific Files
139
+
140
+ ```
141
+ .env # always loaded
142
+ .env.local # always loaded, gitignored
143
+ .env.[mode] # only in specified mode
144
+ .env.[mode].local # only in specified mode, gitignored
145
+ ```
146
+
147
+ ### TypeScript Support
148
+
149
+ ```ts
150
+ // vite-env.d.ts
151
+ interface ImportMetaEnv {
152
+ readonly VITE_API_URL: string
153
+ }
154
+
155
+ interface ImportMeta {
156
+ readonly env: ImportMetaEnv
157
+ }
158
+ ```
159
+
160
+ ### HTML Replacement
161
+
162
+ ```html
163
+ <p>Running in %MODE%</p>
164
+ <script>window.API = "%VITE_API_URL%"</script>
165
+ ```
166
+
167
+ ## CSS
168
+
169
+ ### CSS Modules
170
+
171
+ Any `.module.css` file treated as CSS module:
172
+
173
+ ```ts
174
+ import styles from './component.module.css'
175
+ element.className = styles.button
176
+ ```
177
+
178
+ ### Lightning CSS (Vite 8 default for minification)
179
+
180
+ Lightning CSS is now the default CSS minifier. For full Lightning CSS processing:
181
+
182
+ ```ts
183
+ export default defineConfig({
184
+ css: {
185
+ transformer: 'lightningcss',
186
+ lightningcss: {
187
+ // Lightning CSS options
188
+ },
189
+ },
190
+ })
191
+ ```
192
+
193
+ ## JSON Import
194
+
195
+ ```ts
196
+ import pkg from './package.json'
197
+ import { version } from './package.json' // Named import with tree-shaking
198
+ ```
199
+
200
+ ## HMR API
201
+
202
+ ```ts
203
+ if (import.meta.hot) {
204
+ import.meta.hot.accept((newModule) => {
205
+ // Handle update
206
+ })
207
+
208
+ import.meta.hot.dispose((data) => {
209
+ // Cleanup before module is replaced
210
+ })
211
+
212
+ import.meta.hot.invalidate() // Force full reload
213
+ }
214
+ ```
215
+
216
+ <!--
217
+ Source references:
218
+ - https://vite.dev/guide/features
219
+ - https://vite.dev/guide/env-and-mode
220
+ - https://vite.dev/guide/assets
221
+ - https://vite.dev/guide/api-hmr
222
+ -->
@@ -0,0 +1,294 @@
1
+ ---
2
+ name: vite-plugin-api
3
+ description: Vite plugin authoring with Rolldown hooks and Vite-specific hooks (Vite 8)
4
+ ---
5
+
6
+ # Vite Plugin API
7
+
8
+ Vite plugins extend Rolldown's plugin interface with Vite-specific hooks. Refer to Rolldown's plugin documentation for the base API.
9
+
10
+ ## Basic Structure
11
+
12
+ ```ts
13
+ import type { Plugin } from 'vite'
14
+
15
+ function myPlugin(): Plugin {
16
+ return {
17
+ name: 'my-plugin',
18
+ // hooks...
19
+ }
20
+ }
21
+ ```
22
+
23
+ ## Vite-Specific Hooks
24
+
25
+ ### config
26
+
27
+ Modify config before resolution:
28
+
29
+ ```ts
30
+ const plugin = () => ({
31
+ name: 'add-alias',
32
+ config: () => ({
33
+ resolve: {
34
+ alias: { foo: 'bar' },
35
+ },
36
+ }),
37
+ })
38
+ ```
39
+
40
+ ### configResolved
41
+
42
+ Access final resolved config:
43
+
44
+ ```ts
45
+ const plugin = () => {
46
+ let config: ResolvedConfig
47
+ return {
48
+ name: 'read-config',
49
+ configResolved(resolvedConfig) {
50
+ config = resolvedConfig
51
+ },
52
+ transform(code, id) {
53
+ if (config.command === 'serve') { /* dev */ }
54
+ },
55
+ }
56
+ }
57
+ ```
58
+
59
+ ### configureServer
60
+
61
+ Add custom middleware to dev server:
62
+
63
+ ```ts
64
+ const plugin = () => ({
65
+ name: 'custom-middleware',
66
+ configureServer(server) {
67
+ server.middlewares.use((req, res, next) => {
68
+ // handle request
69
+ next()
70
+ })
71
+ },
72
+ })
73
+ ```
74
+
75
+ Return function to run **after** internal middlewares:
76
+
77
+ ```ts
78
+ configureServer(server) {
79
+ return () => {
80
+ server.middlewares.use((req, res, next) => {
81
+ // runs after Vite's middlewares
82
+ })
83
+ }
84
+ }
85
+ ```
86
+
87
+ ### transformIndexHtml
88
+
89
+ Transform HTML entry files:
90
+
91
+ ```ts
92
+ const plugin = () => ({
93
+ name: 'html-transform',
94
+ transformIndexHtml(html) {
95
+ return html.replace(/<title>(.*?)<\/title>/, '<title>New Title</title>')
96
+ },
97
+ })
98
+ ```
99
+
100
+ Inject tags:
101
+
102
+ ```ts
103
+ transformIndexHtml() {
104
+ return [
105
+ { tag: 'script', attrs: { src: '/inject.js' }, injectTo: 'body' },
106
+ ]
107
+ }
108
+ ```
109
+
110
+ ### handleHotUpdate
111
+
112
+ Custom HMR handling:
113
+
114
+ ```ts
115
+ handleHotUpdate({ server, modules, timestamp }) {
116
+ server.ws.send({ type: 'custom', event: 'special-update', data: {} })
117
+ return [] // empty = skip default HMR
118
+ }
119
+ ```
120
+
121
+ ## Virtual Modules
122
+
123
+ Serve virtual content without files on disk:
124
+
125
+ ```ts
126
+ import { exactRegex } from '@rolldown/pluginutils'
127
+
128
+ const plugin = () => {
129
+ const virtualModuleId = 'virtual:my-module'
130
+ const resolvedId = '\0' + virtualModuleId
131
+
132
+ return {
133
+ name: 'virtual-module',
134
+ resolveId: {
135
+ filter: { id: exactRegex(virtualModuleId) },
136
+ handler() {
137
+ return resolvedId
138
+ },
139
+ },
140
+ load: {
141
+ filter: { id: exactRegex(resolvedId) },
142
+ handler() {
143
+ return `export const msg = "from virtual module"`
144
+ },
145
+ },
146
+ }
147
+ }
148
+ ```
149
+
150
+ Usage:
151
+
152
+ ```ts
153
+ import { msg } from 'virtual:my-module'
154
+ ```
155
+
156
+ Convention: prefix user-facing path with `virtual:`, prefix resolved id with `\0`.
157
+
158
+ **Note:** The older function-based syntax (`resolveId(id) { ... }`) still works — the filter-based syntax above is the newer, more performant pattern from Rolldown.
159
+
160
+ ## Hook Filters (Vite 8 / Rolldown)
161
+
162
+ Hook filters reduce overhead by letting plugins declare which files they care about, so hooks are only called when relevant:
163
+
164
+ ```ts
165
+ {
166
+ name: 'transform-ts',
167
+ transform: {
168
+ filter: { id: /\.(ts|tsx)$/ },
169
+ handler(code, id) {
170
+ // Only called for .ts/.tsx files
171
+ return { code: transform(code), map: null }
172
+ },
173
+ },
174
+ }
175
+ ```
176
+
177
+ ## moduleType in load/transform (Vite 8)
178
+
179
+ When converting non-JS content to JavaScript, you must specify `moduleType: 'js'` so Rolldown interprets the output correctly:
180
+
181
+ ```ts
182
+ {
183
+ name: 'txt-loader',
184
+ load(id) {
185
+ if (id.endsWith('.txt')) {
186
+ const content = fs.readFileSync(id, 'utf-8')
187
+ return {
188
+ code: `export default ${JSON.stringify(content)}`,
189
+ moduleType: 'js',
190
+ }
191
+ }
192
+ },
193
+ }
194
+ ```
195
+
196
+ ## Plugin Ordering
197
+
198
+ Use `enforce` to control execution order:
199
+
200
+ ```ts
201
+ {
202
+ name: 'pre-plugin',
203
+ enforce: 'pre', // runs before core plugins
204
+ }
205
+
206
+ {
207
+ name: 'post-plugin',
208
+ enforce: 'post', // runs after build plugins
209
+ }
210
+ ```
211
+
212
+ Order: Alias → `enforce: 'pre'` → Core → User (no enforce) → Build → `enforce: 'post'` → Post-build
213
+
214
+ ## Conditional Application
215
+
216
+ ```ts
217
+ {
218
+ name: 'build-only',
219
+ apply: 'build', // or 'serve'
220
+ }
221
+
222
+ // Function form:
223
+ {
224
+ apply(config, { command }) {
225
+ return command === 'build' && !config.build.ssr
226
+ }
227
+ }
228
+ ```
229
+
230
+ ## Universal Hooks (from Rolldown)
231
+
232
+ These work in both dev and build:
233
+
234
+ - `resolveId(id, importer)` — Resolve import paths
235
+ - `load(id)` — Load module content
236
+ - `transform(code, id)` — Transform module code
237
+
238
+ ```ts
239
+ transform(code, id) {
240
+ if (id.endsWith('.custom')) {
241
+ return { code: compile(code), map: null }
242
+ }
243
+ }
244
+ ```
245
+
246
+ **Note:** `moduleParsed` hook is NOT called during dev in Vite 8.
247
+
248
+ ## Detecting Rolldown at Runtime
249
+
250
+ ```ts
251
+ transform(code, id) {
252
+ if (this.meta.rolldownVersion) {
253
+ // Running on Rolldown-powered Vite (8+)
254
+ }
255
+ }
256
+ ```
257
+
258
+ ## Client-Server Communication
259
+
260
+ Server to client:
261
+
262
+ ```ts
263
+ configureServer(server) {
264
+ server.ws.send('my:event', { msg: 'hello' })
265
+ }
266
+ ```
267
+
268
+ Client side:
269
+
270
+ ```ts
271
+ if (import.meta.hot) {
272
+ import.meta.hot.on('my:event', (data) => {
273
+ console.log(data.msg)
274
+ })
275
+ }
276
+ ```
277
+
278
+ Client to server:
279
+
280
+ ```ts
281
+ // Client
282
+ import.meta.hot.send('my:from-client', { msg: 'Hey!' })
283
+
284
+ // Server
285
+ server.ws.on('my:from-client', (data, client) => {
286
+ client.send('my:ack', { msg: 'Got it!' })
287
+ })
288
+ ```
289
+
290
+ <!--
291
+ Source references:
292
+ - https://vite.dev/guide/api-plugin
293
+ - https://vite.dev/guide/migration
294
+ -->
@@ -0,0 +1,108 @@
1
+ ---
2
+ name: vite-environment-api
3
+ description: Vite 6+ Environment API for multiple runtime environments
4
+ ---
5
+
6
+ # Environment API (Vite 6+)
7
+
8
+ The Environment API formalizes multiple runtime environments beyond the traditional client/SSR split.
9
+
10
+ ## Concept
11
+
12
+ Before Vite 6: Two implicit environments (`client` and `ssr`).
13
+
14
+ Vite 6+: Configure as many environments as needed (browser, node server, edge server, etc.).
15
+
16
+ ## Basic Configuration
17
+
18
+ For SPA/MPA, nothing changes—options apply to the implicit `client` environment:
19
+
20
+ ```ts
21
+ export default defineConfig({
22
+ build: { sourcemap: false },
23
+ optimizeDeps: { include: ['lib'] },
24
+ })
25
+ ```
26
+
27
+ ## Multiple Environments
28
+
29
+ ```ts
30
+ export default defineConfig({
31
+ build: { sourcemap: false }, // Inherited by all environments
32
+ optimizeDeps: { include: ['lib'] }, // Client only
33
+ environments: {
34
+ // SSR environment
35
+ server: {},
36
+ // Edge runtime environment
37
+ edge: {
38
+ resolve: { noExternal: true },
39
+ },
40
+ },
41
+ })
42
+ ```
43
+
44
+ Environments inherit top-level config. Some options (like `optimizeDeps`) only apply to `client` by default.
45
+
46
+ ## Environment Options
47
+
48
+ ```ts
49
+ interface EnvironmentOptions {
50
+ define?: Record<string, any>
51
+ resolve?: EnvironmentResolveOptions
52
+ optimizeDeps: DepOptimizationOptions
53
+ consumer?: 'client' | 'server'
54
+ dev: DevOptions
55
+ build: BuildOptions
56
+ }
57
+ ```
58
+
59
+ ## Custom Environment Instances
60
+
61
+ Runtime providers can define custom environments:
62
+
63
+ ```ts
64
+ import { customEnvironment } from 'vite-environment-provider'
65
+
66
+ export default defineConfig({
67
+ environments: {
68
+ ssr: customEnvironment({
69
+ build: { outDir: '/dist/ssr' },
70
+ }),
71
+ },
72
+ })
73
+ ```
74
+
75
+ Example: Cloudflare's Vite plugin runs code in `workerd` runtime during development.
76
+
77
+ ## Backward Compatibility
78
+
79
+ - `server.moduleGraph` returns mixed client/SSR view
80
+ - `ssrLoadModule` still works
81
+ - Existing SSR apps work unchanged
82
+
83
+ ## When to Use
84
+
85
+ - **End users**: Usually don't need to configure—frameworks handle it
86
+ - **Plugin authors**: Use for environment-aware transformations
87
+ - **Framework authors**: Create custom environments for their runtime needs
88
+
89
+ ## Plugin Environment Access
90
+
91
+ Plugins can access environment in hooks:
92
+
93
+ ```ts
94
+ {
95
+ name: 'env-aware',
96
+ transform(code, id, options) {
97
+ if (options?.ssr) {
98
+ // SSR-specific transform
99
+ }
100
+ },
101
+ }
102
+ ```
103
+
104
+ <!--
105
+ Source references:
106
+ - https://vite.dev/guide/api-environment
107
+ - https://vite.dev/blog/announcing-vite6
108
+ -->