css-loader
Advanced tools
Comparing version 0.8.0 to 0.9.0
47
index.js
@@ -9,3 +9,3 @@ /* | ||
module.exports = function(content) { | ||
module.exports = function(content, map) { | ||
this.cacheable && this.cacheable(); | ||
@@ -17,2 +17,3 @@ var result = []; | ||
var forceMinimize = query.minimize; | ||
var importLoaders = parseInt(query.importLoaders, 10) || 0; | ||
var minimize = typeof forceMinimize !== "undefined" ? !!forceMinimize : (this && this.minimize); | ||
@@ -34,3 +35,6 @@ var tree = csso.parse(content, "stylesheet"); | ||
var importUrl = "-!" + | ||
this.loaders.slice(this.loaderIndex).map(function(x) { return x.request; }).join("!") + "!" + | ||
this.loaders.slice( | ||
this.loaderIndex, | ||
this.loaderIndex + 1 + importLoaders | ||
).map(function(x) { return x.request; }).join("!") + "!" + | ||
loaderUtils.urlToRequest(imp.url); | ||
@@ -63,21 +67,26 @@ result.push("require(" + JSON.stringify(require.resolve("./mergeImport")) + ")(exports, require(" + JSON.stringify(importUrl) + "), " + JSON.stringify(imp.media.join("")) + ");"); | ||
var request = loaderUtils.getCurrentRequest(this); | ||
var sourceMap = new SourceMapGenerator({ | ||
file: request | ||
}); | ||
var lines = content.split("\n").length; | ||
for(var i = 0; i < lines; i++) { | ||
sourceMap.addMapping({ | ||
generated: { | ||
line: i+1, | ||
column: 0 | ||
}, | ||
source: cssRequest, | ||
original: { | ||
line: i+1, | ||
column: 0 | ||
}, | ||
if(!map) { | ||
var sourceMap = new SourceMapGenerator({ | ||
file: request | ||
}); | ||
var lines = content.split("\n").length; | ||
for(var i = 0; i < lines; i++) { | ||
sourceMap.addMapping({ | ||
generated: { | ||
line: i+1, | ||
column: 0 | ||
}, | ||
source: cssRequest, | ||
original: { | ||
line: i+1, | ||
column: 0 | ||
}, | ||
}); | ||
} | ||
sourceMap.setSourceContent(cssRequest, content); | ||
map = JSON.stringify(sourceMap.toJSON()); | ||
} else if(typeof map !== "string") { | ||
map = JSON.stringify(map); | ||
} | ||
sourceMap.setSourceContent(cssRequest, content); | ||
result.push("exports.push([module.id, " + css + ", \"\", " + JSON.stringify(sourceMap.toJSON()) + "]);"); | ||
result.push("exports.push([module.id, " + css + ", \"\", " + map + "]);"); | ||
} else { | ||
@@ -84,0 +93,0 @@ result.push("exports.push([module.id, " + css + ", \"\"]);"); |
{ | ||
"name": "css-loader", | ||
"version": "0.8.0", | ||
"version": "0.9.0", | ||
"author": "Tobias Koppers @sokra", | ||
@@ -5,0 +5,0 @@ "description": "css loader module for webpack", |
@@ -69,2 +69,20 @@ # css loader for webpack | ||
### importing and chained loaders | ||
The query parameter `importLoaders` allow to configure which loaders should be applied to `@import`ed resources. | ||
`importLoaders` (int): That many loaders after the css-loader are used to import resources. | ||
Examples: | ||
``` js | ||
require("style-loader!css-loader?importLoaders=1!autoprefixer-loader!...") | ||
// => imported resources are handled this way: | ||
require("css-loader?importLoaders=1!autoprefixer-loader!...") | ||
require("style-loader!css-loader!stylus-loader!...") | ||
// => imported resources are handled this way: | ||
require("css-loader!...") | ||
``` | ||
### Minification | ||
@@ -71,0 +89,0 @@ |
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
9722
183
104