Skip to content

Commit

Permalink
Add examples of utils.createHash
Browse files Browse the repository at this point in the history
  • Loading branch information
JLHwung authored Jul 15, 2024
1 parent 2ec1209 commit e072640
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/content/api/loaders.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -569,10 +569,11 @@ Example values: `'web'`, `'node'`

<Badge text="5.27.0+" />

Access to `contextify` and `absolutify` utilities.
Access to the following utilities.

- `contextify`: Return a new request string avoiding absolute paths when possible.
- `absolutify`: Return a new request string using absolute paths when possible.
- `contextify`: Return a new request string avoiding absolute paths when possible.
- `createHash`: Return a new Hash object from provided hash function.

**my-sync-loader.js**

Expand All @@ -583,6 +584,11 @@ module.exports = function (content) {
this.utils.absolutify(this.context, './index.js')
);
this.utils.absolutify(this.context, this.resourcePath);
const mainHash = this.utils.createHash(
this._compilation.outputOptions.hashFunction
);
mainHash.update(content);
mainHash.digest("hex");

Check failure on line 591 in src/content/api/loaders.mdx

View workflow job for this annotation

GitHub Actions / Lint (ubuntu-latest, latest)

Strings must use singlequote
//
return content;
};
Expand Down

0 comments on commit e072640

Please sign in to comment.