From 96e97eeaed3a02a32de6ae41fd3e052990fa7093 Mon Sep 17 00:00:00 2001 From: madzhup Date: Thu, 12 Jul 2018 16:43:31 +0300 Subject: [PATCH] fix(webpack): Fix webpack loader when another loader used before --- packages/webpack/src/index.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/packages/webpack/src/index.js b/packages/webpack/src/index.js index dd3a1f28..4a0bd048 100644 --- a/packages/webpack/src/index.js +++ b/packages/webpack/src/index.js @@ -41,11 +41,17 @@ function svgrLoader(source) { ) }) - readSvg() - .then(svg => convert(svg, options, { webpack: { previousExport } })) - .then(jsCode => (babel ? pBabelTransform(jsCode) : jsCode)) - .then(result => callback(null, result)) - .catch(err => callback(err)) + const tranformSvg = svg => + convert(svg, options, { webpack: { previousExport } }) + .then(jsCode => (babel ? pBabelTransform(jsCode) : jsCode)) + .then(result => callback(null, result)) + .catch(err => callback(err)) + + if (exportMatches) { + readSvg().then(tranformSvg) + } else { + tranformSvg(source) + } } export default svgrLoader