Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 3 additions & 20 deletions config/build-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,28 +189,11 @@ export default defineConfig({

- **型:** `boolean | { fileName?: string }`
- **デフォルト:** `false`
- **関連:** [License](/guide/features#license)

`true` に設定すると、ビルドによってバンドルされたすべての依存関係のライセンスを含む `.vite/license.md` ファイルが生成されます。これをホストして、アプリで使用されている依存関係を表示および承認できます。`fileName` を渡すと、`outDir` からの相対パスでライセンスファイル名として使用されます。出力例は次のようになります:
`true` に設定すると、ビルドによってバンドルされたすべての依存関係のライセンスを含む `.vite/license.md` ファイルが生成されます。

```md
# Licenses

The app bundles dependencies which contain the following licenses:

## dep-1 - 1.2.3 (CC0-1.0)

CC0 1.0 Universal

...

## dep-2 - 4.5.6 (MIT)

MIT License

...
```

`fileName` が `.json` で終わる場合、代わりに生の JSON メタデータが生成され、さらなる処理に使用できます。たとえば:
`fileName` を渡すと、`outDir` からの相対パスでライセンスファイル名として使用されます。これが `.json` で終わる場合、代わりに生の JSON メタデータが生成され、さらなる処理に使用できます。たとえば:

```json
[
Expand Down
36 changes: 36 additions & 0 deletions guide/features.md
Original file line number Diff line number Diff line change
Expand Up @@ -789,6 +789,42 @@ CSP をデプロイするには、Vite 内部の理由により、特定のデ
[`script-src`](https://developer.mozilla.org/ja/docs/Web/HTTP/Headers/Content-Security-Policy/script-src) に対して `data:` を許可してはいけません。任意のスクリプトのインジェクションを許してしまうことになります。
:::

## License

Vite は [`build.license`](/config/build-options.md#build-license) オプションを使用して、ビルドで使用されるすべての依存関係のライセンスのファイルを生成できます。これをホストして、アプリで使用されている依存関係を表示および承認できます。

```js twoslash [vite.config.js]
import { defineConfig } from 'vite'

export default defineConfig({
build: {
license: true,
},
})
```

これにより、次のような出力の `.vite/license.md` ファイルが生成されます:

```md
# Licenses

The app bundles dependencies which contain the following licenses:

## dep-1 - 1.2.3 (CC0-1.0)

CC0 1.0 Universal

...

## dep-2 - 4.5.6 (MIT)

MIT License

...
```

異なるパスでファイルを提供するには、たとえば `{ fileName: 'license.md' }` を渡すことで、`https://example.com/license.md` で提供されるようになります。詳細については、[`build.license`](/config/build-options.md#build-license) ドキュメントを参照してください。

## ビルドの最適化 {#build-optimizations}

> 以下にリストされている機能は、ビルドプロセスの一部として自動的に適用され、無効にする場合を除いて、明示的に設定する必要はありません。
Expand Down