Skip to content

Commit

Permalink
fix(index): don't fail on 'sourceMap: false' && emit a warning instea…
Browse files Browse the repository at this point in the history
…d, when previous map found (`options.sourceMap`)
  • Loading branch information
michael-ciniawsky committed May 9, 2017
1 parent fbef238 commit 159b66a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

2 comments on commit 159b66a

@evan-scott-zocdoc
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"enterily" -> "entirely"

@michael-ciniawsky
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feel free to send PR 😛 otherwise thx

Please sign in to comment.