diff --git a/docs/05-plugin-development.md b/docs/05-plugin-development.md index 7686f344363..eefbd4f03d2 100644 --- a/docs/05-plugin-development.md +++ b/docs/05-plugin-development.md @@ -262,16 +262,15 @@ Type: `({chunkId: string, fileName: string, format: string, moduleId: string, re Kind: `sync, first`
Phase: `generate` -Allows to customize how Rollup resolves URLs of files that were emitted by plugins via `this.emitAsset` or `this.emitChunk`. By default, Rollup will generate code for `import.meta.ROLLUP_ASSET_URL_assetReferenceId` and `import.meta.ROLLUP_CHUNK_URL_chunkReferenceId` that should correctly generate absolute URLs of emitted files independent of the output format and the host system where the code is deployed. +Allows to customize how Rollup resolves URLs of files that were emitted by plugins via `this.emitFile`. By default, Rollup will generate code for `import.meta.ROLLUP_FILE_URL_referenceId` that should correctly generate absolute URLs of emitted files independent of the output format and the host system where the code is deployed. For that, all formats except CommonJS and UMD assume that they run in a browser environment where `URL` and `document` are available. In case that fails or to generate more optimized code, this hook can be used to customize this behaviour. To do that, the following information is available: -- `assetReferenceId`: The asset reference id if we are resolving `import.meta.ROLLUP_ASSET_URL_assetReferenceId`, otherwise `null`. - `chunkId`: The id of the chunk this file is referenced from. -- `chunkReferenceId`: The chunk reference id if we are resolving `import.meta.ROLLUP_CHUNK_URL_chunkReferenceId`, otherwise `null`. - `fileName`: The path and file name of the emitted asset, relative to `output.dir` without a leading `./`. - `format`: The rendered output format. - `moduleId`: The id of the original module this file is referenced from. Useful for conditionally resolving certain assets differently. +- `referenceId`: The reference id of the file. - `relativePath`: The path and file name of the emitted file, relative to the chunk the file is referenced from. This will path will contain no leading `./` but may contain a leading `../`. Note that since this hook has access to the filename of the current chunk, its return value will not be considered when generating the hash of this chunk.