From 40c05591c9ffe994a357fb82681a2491ae993b34 Mon Sep 17 00:00:00 2001 From: fergaldoyle Date: Mon, 7 Sep 2015 12:50:09 +0100 Subject: [PATCH 1/3] If base option is set to a relative path, overwrite compiler.outputPath and path --- index.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/index.js b/index.js index 4513d0f..cd45db8 100644 --- a/index.js +++ b/index.js @@ -63,6 +63,7 @@ module.exports = function (options, wp, done) { var webpack = wp || require('webpack'); var entry = []; var entries = Object.create(null); + var _file; var stream = through(function (file) { if (file.isNull()) { @@ -77,6 +78,9 @@ module.exports = function (options, wp, done) { entry = entry || []; entry.push(file.path); } + + _file = file; + }, function () { var self = this; options.output = options.output || {}; @@ -139,6 +143,17 @@ module.exports = function (options, wp, done) { path = path.split('?')[0]; } var contents = fs.readFileSync(path); + + // only do this if a relative base has been set in gulp.src options + var pathParts + if (_file.base.indexOf('.') === 0) { + pathParts = _file.path.split('\\'); + pathParts.pop(); + pathParts.push(path.split('\\').pop()); + path = pathParts.join('\\'); + compiler.outputPath = _file.base; + } + self.queue(new File({ base: compiler.outputPath, path: path, From d4ba6a20edb886e47ab9c0867fad4d9ccdab55cb Mon Sep 17 00:00:00 2001 From: fergaldoyle Date: Mon, 7 Sep 2015 12:58:40 +0100 Subject: [PATCH 2/3] Semicolon --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index cd45db8..28af3a9 100644 --- a/index.js +++ b/index.js @@ -145,7 +145,7 @@ module.exports = function (options, wp, done) { var contents = fs.readFileSync(path); // only do this if a relative base has been set in gulp.src options - var pathParts + var pathParts; if (_file.base.indexOf('.') === 0) { pathParts = _file.path.split('\\'); pathParts.pop(); From dc525f424b8c1c94a5cd95c614f6d92ade0e09d8 Mon Sep 17 00:00:00 2001 From: fergaldoyle Date: Mon, 7 Sep 2015 14:48:15 +0100 Subject: [PATCH 3/3] Fixed when watch=true --- index.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 28af3a9..a79741f 100644 --- a/index.js +++ b/index.js @@ -145,17 +145,17 @@ module.exports = function (options, wp, done) { var contents = fs.readFileSync(path); // only do this if a relative base has been set in gulp.src options - var pathParts; + var pathParts, outputPath = compiler.outputPath; if (_file.base.indexOf('.') === 0) { pathParts = _file.path.split('\\'); pathParts.pop(); pathParts.push(path.split('\\').pop()); path = pathParts.join('\\'); - compiler.outputPath = _file.base; + outputPath = _file.base; } self.queue(new File({ - base: compiler.outputPath, + base: outputPath, path: path, contents: contents }));