Skip to content

Commit fd7b75f

Browse files
committed
Meta tweaks
1 parent 88cf6f4 commit fd7b75f

File tree

3 files changed

+9
-13
lines changed

3 files changed

+9
-13
lines changed

index.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,13 @@ module.exports = class AddAssetPlugin {
77
}
88

99
apply(compiler) {
10-
compiler.hooks.emit.tapAsync('AddAssetPlugin', async (compilation, callback) => {
10+
compiler.hooks.emit.tapPromise('AddAssetPlugin', async compilation => {
1111
const source = typeof this.source === 'string' ? this.source : await this.source(compilation);
1212

1313
compilation.assets[this.filePath] = {
1414
source: () => source,
1515
size: () => source.length
1616
};
17-
18-
callback();
1917
});
2018
}
2119
};

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "add-asset-webpack-plugin",
33
"version": "0.1.0",
4-
"description": "Dynamically add an asset to the webpack graph",
4+
"description": "Dynamically add an asset to the Webpack graph",
55
"license": "MIT",
66
"repository": "sindresorhus/add-asset-webpack-plugin",
77
"author": {
@@ -29,13 +29,13 @@
2929
"file"
3030
],
3131
"devDependencies": {
32-
"ava": "^1.3.1",
32+
"ava": "^1.4.1",
3333
"pify": "^4.0.1",
34-
"tempy": "^0.2.1",
35-
"webpack": "^4.29.6",
34+
"tempy": "^0.3.0",
35+
"webpack": "^4.30.0",
3636
"xo": "^0.24.0"
3737
},
3838
"peerDependencies": {
39-
"webpack": "4.x"
39+
"webpack": ">=4"
4040
}
4141
}

readme.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# add-asset-webpack-plugin [![Build Status](https://travis-ci.org/sindresorhus/add-asset-webpack-plugin.svg?branch=master)](https://travis-ci.org/sindresorhus/add-asset-webpack-plugin)
22

3-
> Dynamically add an asset to the [webpack](https://webpack.js.org) graph
3+
> Dynamically add an asset to the [Webpack](https://webpack.js.org) graph
44
55

66
## Install
@@ -38,13 +38,11 @@ Relative file path for the asset.
3838

3939
#### source
4040

41-
Type: `string` `Function => string | Promise<string>`
41+
Type: `string | (compilation => string | Promise<string>)`
4242

4343
Asset source or a function that returns the asset source.
4444

45-
If the function returns a promise, it will be awaited.
46-
47-
If a function, it will receive the [`compilation` instance](https://webpack.js.org/api/compilation/).
45+
If a function, it will receive the [`compilation` instance](https://webpack.js.org/api/compilation/). And if the function returns a promise, it will be awaited.
4846

4947

5048
## Related

0 commit comments

Comments
 (0)