From bff4cb031782edae83b65bd082ce5ddf931ca934 Mon Sep 17 00:00:00 2001
From: Thomas Sileghem
Date: Mon, 21 Aug 2017 13:11:53 +0100
Subject: [PATCH] feat(basePath): use basePath for keys only
BREAKING CHANGE:
- basePath is not ignored when publicPath is used
- basepath is only modifying manifest keys
---
README.md | 4 ++--
lib/plugin.js | 5 +++--
spec/plugin.spec.js | 4 ++--
3 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/README.md b/README.md
index c7f7ccd..821b2a8 100644
--- a/README.md
+++ b/README.md
@@ -63,14 +63,14 @@ The manifest filename in your output directory.
Type: `String`
-A path prefix for all file references. Useful for including your output path in the manifest.
+A path prefix for all keys. Useful for including your output path in the manifest.
### `publicPath`
Type: `String`
-A path prefix used only on output files, similar to Webpack's [output.publicPath](https://github.com/webpack/docs/wiki/configuration#outputpublicpath). Ignored if `basePath` was also provided.
+A path prefix used only on output files, similar to Webpack's [output.publicPath](https://github.com/webpack/docs/wiki/configuration#outputpublicpath).
### `stripSrc`
diff --git a/lib/plugin.js b/lib/plugin.js
index d7daea5..7111cf6 100644
--- a/lib/plugin.js
+++ b/lib/plugin.js
@@ -96,10 +96,11 @@ ManifestPlugin.prototype.apply = function(compiler) {
if (this.opts.basePath) {
files = files.map(function(file) {
file.name = this.opts.basePath + file.name;
- file.path = this.opts.basePath + file.path;
return file;
}.bind(this));
- } else if (this.opts.publicPath) {
+ }
+
+ if (this.opts.publicPath) {
// Similar to basePath but only affects the value (similar to how
// output.publicPath turns require('foo/bar') into '/public/foo/bar', see
// https://github.com/webpack/docs/wiki/configuration#outputpublicpath
diff --git a/spec/plugin.spec.js b/spec/plugin.spec.js
index 8f0e0b0..60a82ca 100644
--- a/spec/plugin.spec.js
+++ b/spec/plugin.spec.js
@@ -143,7 +143,7 @@ describe('ManifestPlugin', function() {
}
}, function(manifest, stats) {
expect(manifest).toEqual({
- '/app/one.js': '/app/one.' + stats.hash + '.js'
+ '/app/one.js': 'one.' + stats.hash + '.js'
});
done();
@@ -210,7 +210,7 @@ describe('ManifestPlugin', function() {
}
}, function(manifest, stats) {
expect(manifest).toEqual({
- 'https://www/example.com/one.js': 'https://www/example.com/one.js'
+ 'https://www/example.com/one.js': 'one.js'
});
done();