Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
mrcego committed Feb 10, 2025
1 parent 62642b0 commit 0ef75e2
Show file tree
Hide file tree
Showing 12 changed files with 157 additions and 88 deletions.
4 changes: 2 additions & 2 deletions docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ export default defineConfig({
link: '/guide/api-environment',
},
{
text: 'Instancias de entorno',
text: 'Instancias de Entorno',
link: '/guide/api-environment-instances',
},
{
Expand Down Expand Up @@ -476,7 +476,7 @@ export default defineConfig({
transformPageData(pageData) {
const canonicalUrl = `${ogUrl}/${pageData.relativePath}`
.replace(/\/index\.md$/, '/')
.replace(/\.md$/, '/')
.replace(/\.md$/, '')
pageData.frontmatter.head ??= []
pageData.frontmatter.head.unshift(
['link', { rel: 'canonical', href: canonicalUrl }],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import logoStorybook from './images/storybook.svg'
import logoSvelte from './images/svelte.svg'
import logoVitest from './images/vitest.svg'
import logoVue from './images/vue.svg'
import logoHono from './images/hono.svg'
/**
* The frameworks and tools to display in this section.
Expand Down Expand Up @@ -164,6 +165,13 @@ const frameworks: Framework[] = [
url: 'https://emberjs.com/',
visible: ref(false),
},
{
name: 'Hono',
logo: logoHono,
color: '#ff5c13',
url: 'https://hono.dev/',
visible: ref(false),
},
]
// Starting parameters
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions docs/config/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ También puedes especificar explícitamente un archivo de configuración para us
vite --config my-config.js
```

::: tip COMPILACIÓN DE LA CONFIGURACIÓN
De forma predeterminada, Vite usa `esbuild` para compilar la configuración en un archivo temporal. Esto puede causar problemas al importar archivos TypeScript en un monorepo. Si encuentras algún inconveniente con este enfoque, puedes especificar `--configLoader=runner` para usar el módulo ejecutor en su lugar; este no creará un archivo temporal y transformará cualquier archivo sobre la marcha. Ten en cuenta que el módulo ejecutor no admite CJS en archivos de configuración, pero los paquetes CJS externos deberían funcionar como de costumbre.
:::

## Configuración de Intellisense

Dado que Vite se distribuye con tipados de TypeScript, puedes aprovechar el intellisense de tu IDE con sugerencias de tipo jsdoc:
Expand Down
12 changes: 11 additions & 1 deletion docs/config/preview-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ A menos que se indique lo contrario, las opciones en esta sección solo se aplic

:::

## preview.allowedHosts

- **Tipo:** `string | true`
- **Por defecto:** [`server.allowedHosts`](./server-options#server-allowedhosts)

Los nombres de host a los que Vite tiene permitido responder.
Consulta [`server.allowedHosts`](./server-options#server-allowedhosts) para obtener más detalles.

## preview.port

- **Tipo:** `number`
Expand Down Expand Up @@ -78,7 +86,9 @@ export default defineConfig({
- **Tipo:** `boolean | CorsOptions`
- **Por defecto:** [`server.cors`](#server-proxy)

Configura las CORS para el servidor de vista previa. Esto está habilitado por defecto y permite cualquier origen. Pasa un [objeto de opciones](https://github.com/expressjs/cors#configuration-options) para ajustar el comportamiento o `false` para deshabilitarlo.
Configura CORS para el servidor de vista previa.

Consulta [`server.cors`](./server-options#server-cors) para más detalles.

## preview.headers

Expand Down
23 changes: 22 additions & 1 deletion docs/config/server-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,22 @@ Consulta [el documento de WSL](https://learn.microsoft.com/en-us/windows/wsl/net

:::

## server.allowedHosts

- **Tipo:** `string[] | true`
- **Por defecto:** `[]`

Los nombres de host a los que Vite tiene permitido responder.

Por defecto, `localhost`, los dominios bajo `.localhost` y todas las direcciones IP están permitidos.
Cuando se usa HTTPS, esta verificación se omite.

Si una cadena comienza con `.`, permitirá ese nombre de host sin el `.` y todos los subdominios bajo él.
Por ejemplo, `.example.com` permitirá `example.com`, `foo.example.com` y `foo.bar.example.com`.

Si se configura en `true`, el servidor podrá responder a solicitudes de cualquier host.
Esto **no es recomendable**, ya que lo hace vulnerable a ataques de _DNS rebinding_.

## server.port

- **Tipo:** `number`
Expand Down Expand Up @@ -149,8 +165,13 @@ Consulta [el documento de WSL](https://learn.microsoft.com/en-us/windows/wsl/net
## server.cors

- **Tipo:** `boolean | CorsOptions`
- **Por defecto:** `{ origin: /^https?:\/\/(?:(?:[^:]+\.)?localhost|127\.0\.0\.1|\[::1\])(?::\d+)?$/ }` (permite localhost, `127.0.0.1` y `::1`)

Configura las CORS para el servidor de desarrollo. Esto está habilitado por defecto y permite cualquier origen. Pase un [objeto de opciones](https://github.com/expressjs/cors#configuration-options) para ajustar el comportamiento o `false` para deshabilitarlo.
Configura CORS para el servidor de desarrollo. Pasa un [objeto de opciones](https://github.com/expressjs/cors#configuration-options) para ajustar el comportamiento o usa `true` para permitir cualquier origen.

:::warning
Se recomienda establecer un valor específico en lugar de `true` para evitar exponer el código fuente a orígenes no confiables.
:::

## server.headers

Expand Down
6 changes: 6 additions & 0 deletions docs/guide/api-environment-frameworks.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,13 @@ El `runner` se evalúa de forma prioritaria cuando se accede por primera vez. Te
Dado un servidor Vite configurado en modo middleware como se describe en la [guía de configuración SSR](/guide/ssr#setting-up-the-dev-server), implementemos el middleware SSR usando la API de entorno. El manejo de errores se omite.

```js
import fs from 'node:fs'
import path from 'node:path'
import { fileURLToPath } from 'node:url'
import { createServer } from 'vite'

const __dirname = path.dirname(fileURLToPath(import.meta.url))

const server = await createServer({
server: { middlewareMode: true },
appType: 'custom',
Expand Down
8 changes: 4 additions & 4 deletions docs/guide/api-environment-runtimes.md
Original file line number Diff line number Diff line change
Expand Up @@ -293,28 +293,28 @@ function createWorkerEnvironment(name, config, context) {
const handlerToWorkerListener = new WeakMap()

const workerHotChannel = {
send: (data) => w.postMessage(data),
send: (data) => worker.postMessage(data),
on: (event, handler) => {
if (event === 'connection') return

const listener = (value) => {
if (value.type === 'custom' && value.event === event) {
const client = {
send(payload) {
w.postMessage(payload)
worker.postMessage(payload)
},
}
handler(value.data, client)
}
}
handlerToWorkerListener.set(handler, listener)
w.on('message', listener)
worker.on('message', listener)
},
off: (event, handler) => {
if (event === 'connection') return
const listener = handlerToWorkerListener.get(handler)
if (listener) {
w.off('message', listener)
worker.off('message', listener)
handlerToWorkerListener.delete(handler)
}
},
Expand Down
6 changes: 6 additions & 0 deletions docs/guide/backend-integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ Si necesitas una integración personalizada, puedes seguir los pasos de esta gu
// ---cut---
// vite.config.js
export default defineConfig({
server: {
cors: {
// el origin al que accederás a través del navegador
origin: 'http://my-backend.example.com',
},
},
build: {
// genera el archivo .vite/manifest.json en outDir
manifest: true,
Expand Down
16 changes: 13 additions & 3 deletions docs/guide/build.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,12 @@ Durante el desarrollo, simplemente navega o enlaza a `/nested/` - funcionará co
Durante la compilación, todo lo que necesitas hacer es especificar varios archivos `.html` como puntos de entrada:

```js twoslash [vite.config.js]
import { resolve } from 'path'
import { dirname, resolve } from 'node:path'
import { fileURLToPath } from 'node:url'
import { defineConfig } from 'vite'

const __dirname = dirname(fileURLToPath(import.meta.url))

export default defineConfig({
build: {
rollupOptions: {
Expand All @@ -133,9 +136,12 @@ Cuando sea el momento de empaquetar tu biblioteca para su distribución, usa la
::: code-group
```js twoslash [vite.config.js (entrada única)]
import { resolve } from 'path'
import { dirname, resolve } from 'node:path'
import { fileURLToPath } from 'node:url'
import { defineConfig } from 'vite'

const __dirname = dirname(fileURLToPath(import.meta.url))

export default defineConfig({
build: {
lib: {
Expand All @@ -161,8 +167,12 @@ export default defineConfig({
```
```js twoslash [vite.config.js (multiples entradas)]
import { resolve } from 'path'
import { dirname, resolve } from 'node:path'
import { fileURLToPath } from 'node:url'
import { defineConfig } from 'vite'

const __dirname = dirname(fileURLToPath(import.meta.url))

export default defineConfig({
build: {
lib: {
Expand Down
Loading

0 comments on commit 0ef75e2

Please sign in to comment.