壓縮器
壓縮器會接收一個串流,其中包含正在寫入的套件和原始碼對應的最終內容。它們會傳回一個新的串流,可能會以某種方式轉換資料,以及一個包含要附加的副檔名的 type
。如果沒有傳回 type
,則傳回的串流會取代原始檔案。
import {Compressor} from '@parcel/plugin';
export default new Compressor({
async compress({stream}) {
return {
stream: gzipStream(stream),
type: 'gz'
};
},
});
相關 API
#壓縮器 parcel/packages/core/types/index.js:1709
type Compressor = {|
compress({|
stream: Readable,
options: PluginOptions,
logger: PluginLogger,
|}): Async<?{|
stream: Readable,
type?: string,
|}>,
|}