Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added SourceMap support

  • Loading branch information...
commit 312b9cedd5604b2b2b6044af3a13440b200f21fa 1 parent 4cac434
Tobias Koppers sokra authored
Showing with 15 additions and 3 deletions.
  1. +11 −1 index.js
  2. +4 −2 package.json
12 index.js
View
@@ -3,6 +3,8 @@
Author Tobias Koppers @sokra
*/
var csso = require("csso");
+var SourceNode = require("source-map").SourceNode;
+var loaderUtils = require("loader-utils");
module.exports = function(content) {
this.cacheable && this.cacheable();
var result = [];
@@ -33,7 +35,15 @@ module.exports = function(content) {
return "\"+require(" + JSON.stringify(urlToRequire(url)) + ")+\"";
});
result.push(css);
- return "module.exports =\n\t" + result.join(" +\n\t") + ";";
+ var cssRequest = loaderUtils.getRemainingRequest(this);
+ var node = new SourceNode(1, 0,
+ cssRequest,
+ "module.exports =\n\t" + result.join(" +\n\t") + ";");
+ var stringWithMap = node.toStringWithSourceMap({
+ file: loaderUtils.getCurrentRequest(this)
+ });
+ stringWithMap.map.setSourceContent(cssRequest, content);
+ this.callback(null, stringWithMap.code, stringWithMap.map.toJSON());
}
function urlToRequire(url) {
6 package.json
View
@@ -1,10 +1,12 @@
{
"name": "css-loader",
- "version": "0.5.2",
+ "version": "0.6.0",
"author": "Tobias Koppers @sokra",
"description": "css loader module for webpack",
"dependencies": {
- "csso": "1.3.x"
+ "csso": "1.3.x",
+ "source-map": "0.1.x",
+ "loader-utils": "0.2.x"
},
"devDependencies": {
"mocha": "1.8.x",
Please sign in to comment.
Something went wrong with that request. Please try again.