File tree Expand file tree Collapse file tree 1 file changed +65
-0
lines changed Expand file tree Collapse file tree 1 file changed +65
-0
lines changed Original file line number Diff line number Diff line change @@ -185,6 +185,71 @@ export default defineConfig({
185185})
186186```
187187
188+ ## build.license
189+
190+ - ** 型:** ` boolean | { fileName?: string } `
191+ - ** デフォルト:** ` false `
192+
193+ ` true ` に設定すると、ビルドによってバンドルされたすべての依存関係のライセンスを含む ` .vite/license.md ` ファイルが生成されます。これをホストして、アプリで使用されている依存関係を表示および承認できます。` fileName ` を渡すと、` outDir ` からの相対パスでライセンスファイル名として使用されます。出力例は次のようになります:
194+
195+ ``` md
196+ # Licenses
197+
198+ The app bundles dependencies which contain the following licenses:
199+
200+ ## dep-1 - 1.2.3 (CC0-1.0)
201+
202+ CC0 1.0 Universal
203+
204+ ...
205+
206+ ## dep-2 - 4.5.6 (MIT)
207+
208+ MIT License
209+
210+ ...
211+ ```
212+
213+ ` fileName ` が ` .json ` で終わる場合、代わりに生の JSON メタデータが生成され、さらなる処理に使用できます。たとえば:
214+
215+ ``` json
216+ [
217+ {
218+ "name" : " dep-1" ,
219+ "version" : " 1.2.3" ,
220+ "identifier" : " CC0-1.0" ,
221+ "text" : " CC0 1.0 Universal\n\n ..."
222+ },
223+ {
224+ "name" : " dep-2" ,
225+ "version" : " 4.5.6" ,
226+ "identifier" : " MIT" ,
227+ "text" : " MIT License\n\n ..."
228+ }
229+ ]
230+ ```
231+
232+ ::: tip
233+ ビルドされたコード内でライセンスファイルを参照したい場合は、` build.rollupOptions.output.banner ` を使用してファイルの先頭にコメントを挿入できます。たとえば:
234+
235+ ``` js twoslash [vite.config.js]
236+ import { defineConfig } from ' vite'
237+
238+ export default defineConfig ({
239+ build: {
240+ license: true ,
241+ rollupOptions: {
242+ output: {
243+ banner:
244+ ' /* See licenses of bundled dependencies at https://example.com/license.md */' ,
245+ },
246+ },
247+ },
248+ })
249+ ```
250+
251+ :::
252+
188253## build.manifest
189254
190255- ** 型:** ` boolean | string `
You can’t perform that action at this time.
0 commit comments