diff --git a/middleware.js b/middleware.js index b40d5bd80..f7a301a12 100644 --- a/middleware.js +++ b/middleware.js @@ -5,7 +5,7 @@ var MemoryFileSystem = require("memory-fs"); var mime = require("mime"); var parseRange = require("range-parser"); -var path = require("path"); +var pathIsAbsolute = require("path-is-absolute"); var getFilenameFromUrl = require("./lib/GetFilenameFromUrl"); var pathJoin = require("./lib/PathJoin"); @@ -56,7 +56,8 @@ module.exports = function(compiler, options) { options.filename = new RegExp("^[\/]{0,1}" + str + "$"); } } - if(typeof compiler.outputPath === "string" && !path.isAbsolute(compiler.outputPath)) { + if(typeof compiler.outputPath === "string" && + !pathIsAbsolute.posix(compiler.outputPath) && !pathIsAbsolute.win32(compiler.outputPath)) { throw new Error("`output.path` needs to be an absolute path or `/`."); } diff --git a/package.json b/package.json index 681fafcce..f2c7f0584 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,7 @@ "dependencies": { "memory-fs": "~0.3.0", "mime": "^1.3.4", + "path-is-absolute": "^1.0.0", "range-parser": "^1.0.3" }, "devDependencies": { diff --git a/test/FileSystem.test.js b/test/FileSystem.test.js index 4cb1cfa36..cec7793e1 100644 --- a/test/FileSystem.test.js +++ b/test/FileSystem.test.js @@ -34,4 +34,10 @@ describe("FileSystem", function() { middleware(compiler); }, /output\.path/); }); + + it("should not throw on valid outputPath config for Windows", function() { + var compiler = fakeWebpack(); + compiler.outputPath = "C:/my/path"; + middleware(compiler); + }); });