Skip to content

Commit

Permalink
chore: merge main
Browse files Browse the repository at this point in the history
  • Loading branch information
sapphi-red committed Aug 22, 2023
2 parents cc70dd4 + c39e6c1 commit 9d27b56
Show file tree
Hide file tree
Showing 93 changed files with 979 additions and 1,020 deletions.
7 changes: 4 additions & 3 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// @ts-check
const { builtinModules } = require('node:module')
const { defineConfig } = require('eslint-define-config')
const pkg = require('./package.json')

module.exports = defineConfig({
root: true,
Expand All @@ -16,7 +17,7 @@ module.exports = defineConfig({
parser: '@typescript-eslint/parser',
parserOptions: {
sourceType: 'module',
ecmaVersion: 2021,
ecmaVersion: 2022,
},
rules: {
eqeqeq: ['warn', 'always', { null: 'never' }],
Expand Down Expand Up @@ -173,13 +174,13 @@ module.exports = defineConfig({
'n/no-unsupported-features/es-builtins': [
'error',
{
version: '^14.18.0 || >=16.0.0',
version: pkg.engines.node,
},
],
'n/no-unsupported-features/node-builtins': [
'error',
{
version: '^14.18.0 || >=16.0.0',
version: pkg.engines.node,
},
],
'@typescript-eslint/explicit-module-boundary-types': 'off',
Expand Down
1 change: 0 additions & 1 deletion .github/renovate.json5
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,5 @@

// breaking changes
"kill-port", // `kill-port:^2.0.0 has perf issues (#8392)
"miniflare", // `miniflare:v2.0.0+` only supports node 16.7
],
}
10 changes: 2 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
node_version: [14, 16, 18, 20]
node_version: [18, 20]
include:
# Active LTS + other OS
- os: macos-latest
Expand Down Expand Up @@ -67,14 +67,8 @@ jobs:
packages/create-vite/template**
**.md
- name: Install pnpm (node 14, pnpm 7)
if: steps.changed-files.outputs.only_changed != 'true' && matrix.node_version == 14
uses: pnpm/action-setup@v2.4.0
with:
version: 7

- name: Install pnpm
if: steps.changed-files.outputs.only_changed != 'true' && matrix.node_version != 14
if: steps.changed-files.outputs.only_changed != 'true'
uses: pnpm/action-setup@v2.4.0

- name: Set node version to ${{ matrix.node_version }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ jobs:
- name: Install pnpm
uses: pnpm/action-setup@v2.4.0

- name: Set node version to 16.x
- name: Set node version to 18
uses: actions/setup-node@v3
with:
node-version: 16.x
node-version: 18
registry-url: https://registry.npmjs.org/
cache: "pnpm"

Expand Down
4 changes: 4 additions & 0 deletions docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,10 @@ export default defineConfig({
text: 'Changelog',
link: 'https://github.com/vitejs/vite/blob/main/packages/vite/CHANGELOG.md',
},
{
text: 'Contributing',
link: 'https://github.com/vitejs/vite/blob/main/CONTRIBUTING.md',
},
],
},
],
Expand Down
63 changes: 63 additions & 0 deletions docs/.vitepress/theme/components/AsideSponsors.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,68 @@ const sponsors = computed(() => {
</script>

<template>
<a class="viteconf" href="https://viteconf.org/23" target="_blank">
<img width="22" height="22" src="/viteconf.svg" />
<span>
<p class="extra-info">Free Online Conference</p>
<p class="heading">ViteConf 23 - Oct 5</p>
<p class="extra-info">Get your ticket now!</p>
</span>
</a>
<VPDocAsideSponsors v-if="data" :data="sponsors" />
</template>

<style>
.viteconf {
margin-top: 1rem;
margin-bottom: 1rem;
border-radius: 14px;
padding-left: 2.5rem;
padding-top: 0.4rem;
padding-bottom: 0.4rem;
position: relative;
font-size: 0.9rem;
font-weight: 700;
line-height: 1.1rem;
display: flex;
align-items: center;
justify-content: center;
gap: 0.75rem;
background-color: var(--vp-c-bg-alt);
border: 2px solid var(--vp-c-bg-alt);
transition: border-color 0.5s;
}
.viteconf:hover {
border: 2px solid var(--vp-c-brand-light);
}
.viteconf img {
position: absolute;
left: 1.5rem;
transition: transform 0.5s;
transform: scale(1.25);
}
.viteconf:hover img {
transform: scale(1.75);
}
.viteconf .heading {
background-image: linear-gradient(
120deg,
#b047ff 16%,
var(--vp-c-brand-lighter),
var(--vp-c-brand-lighter)
);
background-clip: text;
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
.viteconf .extra-info {
color: var(--vp-c-text-1);
opacity: 0;
font-size: 0.7rem;
padding-left: 0.1rem;
transition: opacity 0.5s;
}
.viteconf:hover .extra-info {
opacity: 0.9;
}
</style>
5 changes: 2 additions & 3 deletions docs/config/build-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ Specify the directory to nest generated assets under (relative to `build.outDir`
## build.assetsInlineLimit
- **Type:** `number`
- **Default:** `4096` (4kb)
- **Default:** `4096` (4 KiB)
Imported or referenced assets that are smaller than this threshold will be inlined as base64 URLs to avoid extra http requests. Set to `0` to disable inlining altogether.
Expand Down Expand Up @@ -218,7 +218,6 @@ By default, Vite will empty the `outDir` on build if it is inside project root.
## build.copyPublicDir
- **Experimental:** [Give feedback](https://github.com/vitejs/vite/discussions/13807)
- **Type:** `boolean`
- **Default:** `true`
Expand All @@ -236,7 +235,7 @@ Enable/disable gzip-compressed size reporting. Compressing large output files ca
- **Type:** `number`
- **Default:** `500`
Limit for chunk size warnings (in kbs). It is compared against the uncompressed chunk size as the [JavaScript size itself is related to the execution time](https://v8.dev/blog/cost-of-javascript-2019).
Limit for chunk size warnings (in kB). It is compared against the uncompressed chunk size as the [JavaScript size itself is related to the execution time](https://v8.dev/blog/cost-of-javascript-2019).
## build.watch
Expand Down
2 changes: 1 addition & 1 deletion docs/config/shared-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ Enabling this disables named imports.

- **Type:** `ESBuildOptions | false`

`ESBuildOptions` extends [esbuild's own transform options](https://esbuild.github.io/api/#transform-api). The most common use case is customizing JSX:
`ESBuildOptions` extends [esbuild's own transform options](https://esbuild.github.io/api/#transform). The most common use case is customizing JSX:

```js
export default defineConfig({
Expand Down
22 changes: 12 additions & 10 deletions docs/guide/api-javascript.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,15 +201,7 @@ import { preview } from 'vite'
## `PreviewServer`

```ts
interface PreviewServer extends PreviewServerForHook {
resolvedUrls: ResolvedServerUrls
}
```

## `PreviewServerForHook`

```ts
interface PreviewServerForHook {
interface PreviewServer {
/**
* The resolved vite config object
*/
Expand All @@ -228,7 +220,8 @@ interface PreviewServerForHook {
*/
httpServer: http.Server
/**
* The resolved urls Vite prints on the CLI
* The resolved urls Vite prints on the CLI.
* null before server is listening.
*/
resolvedUrls: ResolvedServerUrls | null
/**
Expand Down Expand Up @@ -268,6 +261,15 @@ Deeply merge two Vite configs. `isRoot` represents the level within the Vite con

::: tip NOTE
`mergeConfig` accepts only config in object form. If you have a config in callback form, you should call it before passing into `mergeConfig`.

You can use the `defineConfig` helper to merge a config in callback form with another config:

```ts
export default defineConfig((configEnv) =>
mergeConfig(configAsCallback(configEnv), configAsObject),
)
```

:::

## `searchForWorkspaceRoot`
Expand Down
4 changes: 2 additions & 2 deletions docs/guide/api-plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -311,9 +311,9 @@ Vite plugins can also provide hooks that serve Vite-specific purposes. These hoo

### `configurePreviewServer`

- **Type:** `(server: PreviewServerForHook) => (() => void) | void | Promise<(() => void) | void>`
- **Type:** `(server: PreviewServer) => (() => void) | void | Promise<(() => void) | void>`
- **Kind:** `async`, `sequential`
- **See also:** [PreviewServerForHook](./api-javascript#previewserverforhook)
- **See also:** [PreviewServer](./api-javascript#previewserver)

Same as [`configureServer`](/guide/api-plugin.html#configureserver) but for the preview server. Similarly to `configureServer`, the `configurePreviewServer` hook is called before other middlewares are installed. If you want to inject a middleware **after** other middlewares, you can return a function from `configurePreviewServer`, which will be called after internal middlewares are installed:

Expand Down
4 changes: 4 additions & 0 deletions docs/guide/assets.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
outline: [2, 3]
---

# Static Asset Handling

- Related: [Public Base Path](./build#public-base-path)
Expand Down
4 changes: 2 additions & 2 deletions docs/guide/build.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@ Running `vite build` with this config uses a Rollup preset that is oriented towa
```
$ vite build
building for production...
dist/my-lib.js 0.08 KiB / gzip: 0.07 KiB
dist/my-lib.umd.cjs 0.30 KiB / gzip: 0.16 KiB
dist/my-lib.js 0.08 kB / gzip: 0.07 kB
dist/my-lib.umd.cjs 0.30 kB / gzip: 0.16 kB
```

Recommended `package.json` for your lib:
Expand Down
42 changes: 24 additions & 18 deletions docs/guide/cli.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
outline: [2, 3]
---

# Command Line Interface

## Dev server
Expand All @@ -14,24 +18,25 @@ vite [root]

#### Options

| Options | |
| ------------------------ | ----------------------------------------------------------------- |
| `--host [host]` | Specify hostname (`string`) |
| `--port <port>` | Specify port (`number`) |
| `--https` | Use TLS + HTTP/2 (`boolean`) |
| `--open [path]` | Open browser on startup (`boolean \| string`) |
| `--cors` | Enable CORS (`boolean`) |
| `--strictPort` | Exit if specified port is already in use (`boolean`) |
| `--force` | Force the optimizer to ignore the cache and re-bundle (`boolean`) |
| `-c, --config <file>` | Use specified config file (`string`) |
| `--base <path>` | Public base path (default: `/`) (`string`) |
| `-l, --logLevel <level>` | Info \| warn \| error \| silent (`string`) |
| `--clearScreen` | Allow/disable clear screen when logging (`boolean`) |
| `-d, --debug [feat]` | Show debug logs (`string \| boolean`) |
| `-f, --filter <filter>` | Filter debug logs (`string`) |
| `-m, --mode <mode>` | Set env mode (`string`) |
| `-h, --help` | Display available CLI options |
| `-v, --version` | Display version number |
| Options | |
| ------------------------ | ------------------------------------------------------------------------------------------------------------------ |
| `--host [host]` | Specify hostname (`string`) |
| `--port <port>` | Specify port (`number`) |
| `--https` | Use TLS + HTTP/2 (`boolean`) |
| `--open [path]` | Open browser on startup (`boolean \| string`) |
| `--cors` | Enable CORS (`boolean`) |
| `--strictPort` | Exit if specified port is already in use (`boolean`) |
| `--force` | Force the optimizer to ignore the cache and re-bundle (`boolean`) |
| `-c, --config <file>` | Use specified config file (`string`) |
| `--base <path>` | Public base path (default: `/`) (`string`) |
| `-l, --logLevel <level>` | info \| warn \| error \| silent (`string`) |
| `--clearScreen` | Allow/disable clear screen when logging (`boolean`) |
| `--profile` | Start built-in Node.js inspector (check [Performance bottlenecks](/guide/troubleshooting#performance-bottlenecks)) |
| `-d, --debug [feat]` | Show debug logs (`string \| boolean`) |
| `-f, --filter <filter>` | Filter debug logs (`string`) |
| `-m, --mode <mode>` | Set env mode (`string`) |
| `-h, --help` | Display available CLI options |
| `-v, --version` | Display version number |

## Build

Expand Down Expand Up @@ -65,6 +70,7 @@ vite build [root]
| `--base <path>` | Public base path (default: `/`) (`string`) |
| `-l, --logLevel <level>` | Info \| warn \| error \| silent (`string`) |
| `--clearScreen` | Allow/disable clear screen when logging (`boolean`) |
| `--profile` | Start built-in Node.js inspector (check [Performance bottlenecks](/guide/troubleshooting#performance-bottlenecks)) |
| `-d, --debug [feat]` | Show debug logs (`string \| boolean`) |
| `-f, --filter <filter>` | Filter debug logs (`string`) |
| `-m, --mode <mode>` | Set env mode (`string`) |
Expand Down
4 changes: 4 additions & 0 deletions docs/guide/dep-pre-bundling.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
outline: [2, 3]
---

# Dependency Pre-Bundling

When you run `vite` for the first time, Vite prebundles your project dependencies before loading your site locally. It is done automatically and transparently by default.
Expand Down
2 changes: 1 addition & 1 deletion docs/guide/env-and-mode.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Vite exposes env variables on the special **`import.meta.env`** object. Some bui

- **`import.meta.env.BASE_URL`**: {string} the base url the app is being served from. This is determined by the [`base` config option](/config/shared-options.md#base).

- **`import.meta.env.PROD`**: {boolean} whether the app is running in production.
- **`import.meta.env.PROD`**: {boolean} whether the app is running in production (running the dev server with `NODE_ENV='production'` or running an app built with `NODE_ENV='production'`).

- **`import.meta.env.DEV`**: {boolean} whether the app is running in development (always the opposite of `import.meta.env.PROD`)

Expand Down
16 changes: 7 additions & 9 deletions docs/guide/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,27 +42,25 @@ The supported template presets are:
## Scaffolding Your First Vite Project

::: tip Compatibility Note
Vite requires [Node.js](https://nodejs.org/en/) version 14.18+, 16+. However, some templates require a higher Node.js version to work, please upgrade if your package manager warns about it.
Vite requires [Node.js](https://nodejs.org/en/) version 18+. 20+. However, some templates require a higher Node.js version to work, please upgrade if your package manager warns about it.
:::

With NPM:
::: code-group

```bash
```bash [NPM]
$ npm create vite@latest
```

With Yarn:

```bash
```bash [Yarn]
$ yarn create vite
```

With PNPM:

```bash
```bash [PNPM]
$ pnpm create vite
```

:::

Then follow the prompts!

You can also directly specify the project name and the template you want to use via additional command line options. For example, to scaffold a Vite + Vue project, run:
Expand Down

0 comments on commit 9d27b56

Please sign in to comment.