Skip to content

Commit bfa4b49

Browse files
committed
Merge branch 'master' into next
2 parents 84c6449 + 905a8f1 commit bfa4b49

File tree

6 files changed

+48
-3
lines changed

6 files changed

+48
-3
lines changed

lib/SourceMapDevToolPlugin.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,14 +188,14 @@ class SourceMapDevToolPlugin {
188188
}
189189
let sourceMapFile = compilation.getPath(sourceMapFilename, {
190190
chunk,
191-
filename,
191+
filename: options.fileContext ? path.relative(options.fileContext, filename) : filename,
192192
query,
193193
basename: basename(filename)
194194
});
195195
if(sourceMapFile.indexOf("[contenthash]") !== -1) {
196196
sourceMapFile = sourceMapFile.replace(/\[contenthash\]/g, createHash("md5").update(sourceMapString).digest("hex"));
197197
}
198-
const sourceMapUrl = path.relative(path.dirname(file), sourceMapFile).replace(/\\/g, "/");
198+
const sourceMapUrl = options.publicPath ? options.publicPath + sourceMapFile.replace(/\\/g, "/") : path.relative(path.dirname(file), sourceMapFile).replace(/\\/g, "/");
199199
if(currentSourceMappingURLComment !== false) {
200200
asset.__SourceMapDevToolData[file] = compilation.assets[file] = new ConcatSource(new RawSource(source), currentSourceMappingURLComment.replace(/\[url\]/g, sourceMapUrl));
201201
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "webpack",
3-
"version": "3.8.1",
3+
"version": "3.9.1",
44
"author": "Tobias Koppers @sokra",
55
"description": "Packs CommonJs/AMD modules for the browser. Allows to split your codebase into multiple bundles, which can be loaded on demand. Support loaders to preprocess files, i.e. json, jsx, es7, css, less, ... and your custom stuff.",
66
"dependencies": {

schemas/WebpackOptions.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1634,6 +1634,13 @@
16341634
"description": "Delay the rebuilt after the first change. Value is a time in ms.",
16351635
"type": "number"
16361636
},
1637+
"ignored": {
1638+
"description": "Ignore some files from watching"
1639+
},
1640+
"stdin": {
1641+
"description": "Stop watching when stdin stream has ended",
1642+
"type": "boolean"
1643+
},
16371644
"poll": {
16381645
"description": "Enable polling mode for watching",
16391646
"anyOf": [
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
it("should contain publicPath prefix in [url] and resolve relatively to fileContext", function() {
2+
var fs = require("fs"),
3+
path = require("path");
4+
var source = fs.readFileSync(path.join(__dirname, "public/test.js"), "utf-8");
5+
source.should.containEql("//# sourceMappingURL=https://10.10.10.10/project/sourcemaps/test.js.map");
6+
});
7+
8+
it("should write sourcemap file relative fo fileContext", function() {
9+
var fs = require("fs"),
10+
path = require("path");
11+
fs.existsSync(path.join(__dirname, "sourcemaps/test.js.map")).should.be.true();
12+
});
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
var testObject = {
2+
a: 1
3+
};
4+
5+
module.exports = testObject;
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
var webpack = require("../../../../");
2+
module.exports = {
3+
node: {
4+
__dirname: false,
5+
__filename: false
6+
},
7+
entry: {
8+
"bundle0": ["./index.js"],
9+
"public/test": ["./test.js"],
10+
},
11+
output: {
12+
filename: "[name].js"
13+
},
14+
plugins: [
15+
new webpack.SourceMapDevToolPlugin({
16+
filename: "sourcemaps/[file].map",
17+
publicPath: "https://10.10.10.10/project/",
18+
fileContext: "public"
19+
})
20+
]
21+
};

0 commit comments

Comments
 (0)