File tree Expand file tree Collapse file tree 6 files changed +47
-64
lines changed
Expand file tree Collapse file tree 6 files changed +47
-64
lines changed Original file line number Diff line number Diff line change 1- * text =auto
2- * .js text eol =lf
1+ * text =auto eol =lf
Original file line number Diff line number Diff line change 11language : node_js
22node_js :
3+ - ' 10'
34 - ' 8'
4- - ' 6'
Original file line number Diff line number Diff line change @@ -6,32 +6,16 @@ module.exports = class AddAssetPlugin {
66 this . source = source ;
77 }
88
9- // TODO: For when we target Node.js 8
10- // apply(compiler) {
11- // compiler.plugin('emit', async (compilation, cb) => {
12- // const source = typeof this.source === 'string' ? this.source : await this.source(compilation);
13-
14- // compilation.assets[this.filePath] = {
15- // source: () => source,
16- // size: () => source.length
17- // };
18-
19- // cb();
20- // });
21- // }
22-
239 apply ( compiler ) {
24- compiler . plugin ( 'emit' , ( compilation , cb ) => {
25- const rawSource = typeof this . source === 'string' ? this . source : this . source ( compilation ) ;
10+ compiler . plugin ( 'emit' , async ( compilation , callback ) => {
11+ const source = typeof this . source === 'string' ? this . source : await this . source ( compilation ) ;
2612
27- Promise . resolve ( rawSource ) . then ( source => {
28- compilation . assets [ this . filePath ] = {
29- source : ( ) => source ,
30- size : ( ) => source . length
31- } ;
13+ compilation . assets [ this . filePath ] = {
14+ source : ( ) => source ,
15+ size : ( ) => source . length
16+ } ;
3217
33- cb ( ) ;
34- } ) ;
18+ callback ( ) ;
3519 } ) ;
3620 }
3721} ;
Original file line number Diff line number Diff line change 11{
2- "name" : " add-asset-webpack-plugin" ,
3- "version" : " 0.1.0" ,
4- "description" : " Dynamically add an asset to the webpack graph" ,
5- "license" : " MIT" ,
6- "repository" : " sindresorhus/add-asset-webpack-plugin" ,
7- "author" : {
8- "name" : " Sindre Sorhus" ,
9- 10- "url" : " sindresorhus.com"
11- },
12- "engines" : {
13- "node" : " >=6 "
14- },
15- "scripts" : {
16- "test" : " xo && ava"
17- },
18- "files" : [
19- " index.js"
20- ],
21- "keywords" : [
22- " webpack-plugin" ,
23- " webpack" ,
24- " add" ,
25- " generate" ,
26- " create" ,
27- " make" ,
28- " asset" ,
29- " file"
30- ],
31- "devDependencies" : {
32- "ava" : " * " ,
33- "pify" : " ^3 .0.0 " ,
34- "tempy" : " ^0.2.1" ,
35- "webpack" : " ^3.10.0 " ,
36- "xo" : " * "
37- }
2+ "name" : " add-asset-webpack-plugin" ,
3+ "version" : " 0.1.0" ,
4+ "description" : " Dynamically add an asset to the webpack graph" ,
5+ "license" : " MIT" ,
6+ "repository" : " sindresorhus/add-asset-webpack-plugin" ,
7+ "author" : {
8+ "name" : " Sindre Sorhus" ,
9+ 10+ "url" : " sindresorhus.com"
11+ },
12+ "engines" : {
13+ "node" : " >=8 "
14+ },
15+ "scripts" : {
16+ "test" : " xo && ava"
17+ },
18+ "files" : [
19+ " index.js"
20+ ],
21+ "keywords" : [
22+ " webpack-plugin" ,
23+ " webpack" ,
24+ " add" ,
25+ " generate" ,
26+ " create" ,
27+ " make" ,
28+ " asset" ,
29+ " file"
30+ ],
31+ "devDependencies" : {
32+ "ava" : " ^1.3.1 " ,
33+ "pify" : " ^4 .0.1 " ,
34+ "tempy" : " ^0.2.1" ,
35+ "webpack" : " ^4.29.6 " ,
36+ "xo" : " ^0.24.0 "
37+ }
3838}
Original file line number Diff line number Diff line change @@ -38,7 +38,7 @@ Relative file path for the asset.
3838
3939#### source
4040
41- Type: ` string ` ` Function< string| Promise> `
41+ Type: ` string ` ` Function => string | Promise<string > `
4242
4343Asset source or a function that returns the asset source.
4444
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ import webpack from 'webpack';
55import tempy from 'tempy' ;
66import pify from 'pify' ;
77
8- test ( async t => {
8+ test ( 'main' , async t => {
99 const config = require ( './fixture/webpack.config' ) ;
1010 const cwd = tempy . directory ( ) ;
1111 config . output . path = cwd ;
You can’t perform that action at this time.
0 commit comments