From 159b66ac724fbbb08a1d8cb776a1a03f8471563c Mon Sep 17 00:00:00 2001 From: Michael Ciniawsky Date: Tue, 9 May 2017 13:17:49 +0200 Subject: [PATCH] fix(index): don't fail on 'sourceMap: false' && emit a warning instead, when previous map found (`options.sourceMap`) --- lib/index.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/index.js b/lib/index.js index a4da252c..6fbf9869 100644 --- a/lib/index.js +++ b/lib/index.js @@ -127,8 +127,12 @@ module.exports = function loader (css, map) { css = this.exec(css, this.resource) } - if (typeof map === 'string') map = JSON.parse(map) - if (map && map.mappings) options.map.prev = map + if (!sourceMap && map) { + this.emitWarning(`\n\n ⚠️ PostCSS Loader\n\nPrevious source map found, but options.sourceMap isn't set, this way the loader will discard the source map enterily for performance reasons, see https://github.com/postcss/postcss-loader#sourcemap for more info on the subject\n\n`) + } + + if (sourceMap && typeof map === 'string') map = JSON.parse(map) + if (sourceMap && map) options.map.prev = map return postcss(plugins) .process(css, options)