webpack-assets-manifest 3.0.0 → 3.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +17 -13
- package/readme.md +1 -1
- package/src/WebpackAssetsManifest.js +32 -22
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "webpack-assets-manifest",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.1.1",
|
|
4
4
|
"description": "This Webpack plugin will generate a JSON file that matches the original filename with the hashed version.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -12,6 +12,8 @@
|
|
|
12
12
|
},
|
|
13
13
|
"homepage": "https://github.com/webdeveric/webpack-assets-manifest",
|
|
14
14
|
"keywords": [
|
|
15
|
+
"webpack-assets-manifest",
|
|
16
|
+
"webpack-plugin",
|
|
15
17
|
"webpack",
|
|
16
18
|
"plugin",
|
|
17
19
|
"assets",
|
|
@@ -46,27 +48,29 @@
|
|
|
46
48
|
"lodash.get": "^4.0",
|
|
47
49
|
"lodash.has": "^4.0",
|
|
48
50
|
"mkdirp": "^0.5",
|
|
49
|
-
"schema-utils": "^0.
|
|
50
|
-
"tapable": "^1.0.0"
|
|
51
|
+
"schema-utils": "^1.0.0",
|
|
52
|
+
"tapable": "^1.0.0",
|
|
53
|
+
"webpack-sources": "^1.0.0"
|
|
51
54
|
},
|
|
52
55
|
"peerDependencies": {
|
|
53
|
-
"webpack": ">=4.
|
|
54
|
-
"webpack-sources": "^1.0"
|
|
56
|
+
"webpack": ">=4.4.0"
|
|
55
57
|
},
|
|
56
58
|
"devDependencies": {
|
|
57
|
-
"chai": "^4.0",
|
|
59
|
+
"chai": "^4.2.0",
|
|
58
60
|
"chai-spies": "^1.0.0",
|
|
59
|
-
"
|
|
61
|
+
"css-loader": "^1.0.1",
|
|
62
|
+
"eslint": "^5.9.0",
|
|
60
63
|
"eslint-config-webdeveric": "^0.3",
|
|
61
|
-
"file-loader": "^
|
|
62
|
-
"fs-extra": "^
|
|
64
|
+
"file-loader": "^2.0.0",
|
|
65
|
+
"fs-extra": "^7.0.1",
|
|
63
66
|
"istanbul": "^0.4",
|
|
64
67
|
"jsdoc": "^3.0",
|
|
65
68
|
"memory-fs": "^0.4.1",
|
|
66
|
-
"
|
|
69
|
+
"mini-css-extract-plugin": "^0.4.4",
|
|
70
|
+
"mocha": "^5.2.0",
|
|
67
71
|
"rimraf": "^2.0",
|
|
68
|
-
"superagent": "^3.8.
|
|
69
|
-
"webpack": "^4.
|
|
70
|
-
"webpack-dev-server": "^3.1.
|
|
72
|
+
"superagent": "^3.8.3",
|
|
73
|
+
"webpack": "^4.25.1",
|
|
74
|
+
"webpack-dev-server": "^3.1.10"
|
|
71
75
|
}
|
|
72
76
|
}
|
package/readme.md
CHANGED
|
@@ -9,7 +9,7 @@ This Webpack plugin will generate a JSON file that matches the original filename
|
|
|
9
9
|
|
|
10
10
|
## Installation
|
|
11
11
|
|
|
12
|
-
:warning: Starting with version 2, this plugin works with Webpack 4+.
|
|
12
|
+
:warning: Starting with version 2, this plugin works with Webpack 4+. Version 3.1 requires Webpack 4.4+.
|
|
13
13
|
|
|
14
14
|
```shell
|
|
15
15
|
npm install webpack-assets-manifest --save-dev
|
|
@@ -414,17 +414,21 @@ class WebpackAssetsManifest
|
|
|
414
414
|
getEntrypointFilesGroupedByExtension( entrypoints )
|
|
415
415
|
{
|
|
416
416
|
const files = Object.create(null);
|
|
417
|
+
const removeHMR = f => ! this.isHMR(f);
|
|
418
|
+
const groupFilesByExtension = (files, file) => {
|
|
419
|
+
const ext = this.getExtension(file).replace(/^\.+/, '').toLowerCase();
|
|
417
420
|
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
const ext = this.getExtension(file).replace(/^\.+/, '').toLowerCase();
|
|
421
|
+
files[ ext ] = files[ ext ] || [];
|
|
422
|
+
files[ ext ].push( this.getPublicPath( file ) );
|
|
421
423
|
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
files[ name ][ ext ].push( this.getPublicPath( file ) );
|
|
424
|
+
return files;
|
|
425
|
+
};
|
|
425
426
|
|
|
426
|
-
|
|
427
|
-
|
|
427
|
+
for ( const [ name, entrypoint ] of entrypoints ) {
|
|
428
|
+
files[ name ] = entrypoint
|
|
429
|
+
.getFiles()
|
|
430
|
+
.filter( removeHMR )
|
|
431
|
+
.reduce( groupFilesByExtension, Object.create(null) );
|
|
428
432
|
}
|
|
429
433
|
|
|
430
434
|
return files;
|
|
@@ -504,6 +508,9 @@ class WebpackAssetsManifest
|
|
|
504
508
|
*/
|
|
505
509
|
handleAfterEmit(compilation)
|
|
506
510
|
{
|
|
511
|
+
// Reset the internal mapping of hashed name to original name after every compilation.
|
|
512
|
+
this.assetNames.clear();
|
|
513
|
+
|
|
507
514
|
if ( ! this.options.writeToDisk ) {
|
|
508
515
|
return Promise.resolve();
|
|
509
516
|
}
|
|
@@ -527,24 +534,27 @@ class WebpackAssetsManifest
|
|
|
527
534
|
}
|
|
528
535
|
|
|
529
536
|
/**
|
|
530
|
-
* Record
|
|
537
|
+
* Record asset names
|
|
531
538
|
*
|
|
539
|
+
* @param {object} loaderContext
|
|
532
540
|
* @param {object} module
|
|
533
|
-
* @param {string} hashedFile
|
|
534
541
|
*/
|
|
535
|
-
|
|
542
|
+
handleNormalModuleLoader(loaderContext, module)
|
|
536
543
|
{
|
|
537
|
-
|
|
538
|
-
return false;
|
|
539
|
-
}
|
|
544
|
+
const { emitFile } = loaderContext;
|
|
540
545
|
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
546
|
+
loaderContext.emitFile = (name, content, sourceMap) => {
|
|
547
|
+
if ( ! this.assetNames.has( name ) ) {
|
|
548
|
+
const originalName = path.join(
|
|
549
|
+
path.dirname(name),
|
|
550
|
+
path.basename(module.userRequest)
|
|
551
|
+
);
|
|
552
|
+
|
|
553
|
+
this.assetNames.set(name, originalName);
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
return emitFile.call(module, name, content, sourceMap);
|
|
557
|
+
};
|
|
548
558
|
}
|
|
549
559
|
|
|
550
560
|
/**
|
|
@@ -554,7 +564,7 @@ class WebpackAssetsManifest
|
|
|
554
564
|
*/
|
|
555
565
|
handleCompilation(compilation)
|
|
556
566
|
{
|
|
557
|
-
compilation.hooks.
|
|
567
|
+
compilation.hooks.normalModuleLoader.tap(PLUGIN_NAME, this.handleNormalModuleLoader.bind(this));
|
|
558
568
|
}
|
|
559
569
|
|
|
560
570
|
/**
|