postcss-loader
Advanced tools
Comparing version 0.10.0 to 0.10.1
@@ -0,1 +1,4 @@ | ||
## 0.10.1 | ||
* Better syntax error message (by Andrey Popp). | ||
## 0.10.0 | ||
@@ -2,0 +5,0 @@ * Add `sourceMap` parameter to force inline maps (by 雪狼). |
37
index.js
@@ -1,4 +0,30 @@ | ||
var loaderUtils = require('loader-utils'); | ||
var postcss = require('postcss'); | ||
var formatCodeFrame = require('babel-code-frame'); | ||
var loaderUtils = require('loader-utils'); | ||
var postcss = require('postcss'); | ||
function formatMessage(message, loc, source) { | ||
var formatted = message; | ||
if (loc) { | ||
formatted = formatted + | ||
' (' + loc.line + ':' + loc.column + ')'; | ||
} | ||
if (loc && source) { | ||
formatted = formatted + | ||
'\n\n' + formatCodeFrame(source, loc.line, loc.column) + '\n'; | ||
} | ||
return formatted; | ||
} | ||
function PostCSSLoaderError(name, message, loc, source, error) { | ||
Error.call(this); | ||
Error.captureStackTrace(this, PostCSSLoaderError); | ||
this.name = name; | ||
this.error = error; | ||
this.message = formatMessage(message, loc, source); | ||
this.hideStack = true; | ||
} | ||
PostCSSLoaderError.prototype = Object.create(Error.prototype); | ||
PostCSSLoaderError.prototype.constructor = PostCSSLoaderError; | ||
module.exports = function (source, map) { | ||
@@ -71,4 +97,7 @@ if ( this.cacheable ) this.cacheable(); | ||
if ( error.name === 'CssSyntaxError' ) { | ||
loader.emitError(error.message + error.showSourceCode()); | ||
callback(); | ||
callback(new PostCSSLoaderError( | ||
'Syntax Error', | ||
error.reason, | ||
{ line: error.line, column: error.column }, | ||
error.input.source)); | ||
} else { | ||
@@ -75,0 +104,0 @@ callback(error); |
{ | ||
"name": "postcss-loader", | ||
"version": "0.10.0", | ||
"version": "0.10.1", | ||
"description": "PostCSS loader for webpack", | ||
@@ -10,4 +10,5 @@ "keywords": ["webpack", "loader", "css", "postcss", "postcss-runner"], | ||
"dependencies": { | ||
"loader-utils": "^0.2.15", | ||
"postcss": "^5.1.2" | ||
"babel-code-frame": "^6.11.0", | ||
"loader-utils": "^0.2.15", | ||
"postcss": "^5.1.2" | ||
}, | ||
@@ -14,0 +15,0 @@ "devDependencies": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
13970
93
3
+ Addedbabel-code-frame@^6.11.0
+ Addedbabel-code-frame@6.26.0(transitive)
+ Addedesutils@2.0.3(transitive)
+ Addedjs-tokens@3.0.2(transitive)