From 05c7fb9a2f7e08b89784420a5bae294e75ef5f0b Mon Sep 17 00:00:00 2001 From: benholloway Date: Wed, 9 Dec 2015 17:25:13 +1100 Subject: [PATCH 1/3] added path.resolve() on output path to support project-relative path --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 6e9f3ad..e9b1c82 100644 --- a/index.js +++ b/index.js @@ -33,7 +33,7 @@ function resolveUrlLoader(content, sourceMap) { // details of the file being processed var loader = this, filePath = loader.context, - outputPath = loader.options.output.path, + outputPath = path.resolve(loader.options.output.path), // support relative path edge-case options = defaults(loaderUtils.parseQuery(loader.query), loader.options[camelcase(PACKAGE_NAME)], { absolute : false, sourceMap: false, From 43c33fc8ee8a35d6731e1eadec6b80a6b17fbed4 Mon Sep 17 00:00:00 2001 From: benholloway Date: Wed, 9 Dec 2015 21:16:27 +1100 Subject: [PATCH 2/3] additional comments --- index.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/index.js b/index.js index e9b1c82..bf19822 100644 --- a/index.js +++ b/index.js @@ -33,14 +33,16 @@ function resolveUrlLoader(content, sourceMap) { // details of the file being processed var loader = this, filePath = loader.context, - outputPath = path.resolve(loader.options.output.path), // support relative path edge-case - options = defaults(loaderUtils.parseQuery(loader.query), loader.options[camelcase(PACKAGE_NAME)], { - absolute : false, - sourceMap: false, - fail : false, - silent : false, - root : null - }); + outputPath = path.resolve(loader.options.output.path); // support relative path edge-case + + // prefer loader query, else options object, else default values + var options = defaults(loaderUtils.parseQuery(loader.query), loader.options[camelcase(PACKAGE_NAME)], { + absolute : false, + sourceMap: false, + fail : false, + silent : false, + root : null + }); // validate root directory var resolvedRoot = (typeof options.root === 'string') && path.resolve(options.root), From 5e0c50c1fec3aaabefad552b865ac089ca4c3e67 Mon Sep 17 00:00:00 2001 From: benholloway Date: Wed, 9 Dec 2015 21:21:17 +1100 Subject: [PATCH 3/3] additional comments --- index.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index bf19822..2ef8200 100644 --- a/index.js +++ b/index.js @@ -31,9 +31,11 @@ function resolveUrlLoader(content, sourceMap) { /* jshint validthis:true */ // details of the file being processed + // we would normally use compilation.getPath(options.output.path) to get the most correct outputPath, + // however we need to match to the sass-loader and it does not do so var loader = this, filePath = loader.context, - outputPath = path.resolve(loader.options.output.path); // support relative path edge-case + outputPath = path.resolve(loader.options.output.path); // prefer loader query, else options object, else default values var options = defaults(loaderUtils.parseQuery(loader.query), loader.options[camelcase(PACKAGE_NAME)], {