Skip to content
Open
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
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -757,10 +757,17 @@ module.exports = {
to: "dest/file.txt",
// The `assets` argument is an assets array for the pattern.from ("src/**/*.txt")
transformAll(assets) {
// The assets parameter contains an array of assets
const result = assets.reduce((accumulator, asset) => {
// The asset content can be obtained from `asset.source` using `source` method.
// The asset content is a [`Buffer`](https://nodejs.org/api/buffer.html) object, it could be converted to a `String` to be processed using `content.toString()`
const content = asset.data;
// Each `asset` contains the following data structure:
// {
// data: [`Buffer`], // asset text content can be obtained via asset.data.toString()
// sourceFilename: [`String`],
// absoluteFilename: [`String`],
// }
// The asset content can be obtained from `asset.data`.
// The asset content is a [`Buffer`](https://nodejs.org/api/buffer.html) object, it could be converted to a `String` to be processed using `data.toString()`
const content = asset.data.toString();

accumulator = `${accumulator}${content}\n`;
return accumulator;
Expand Down