Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

css-loader

Package Overview
Dependencies
Maintainers
1
Versions
152
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

css-loader - npm Package Compare versions

Comparing version 0.10.1 to 0.11.0

22

lib/loader.js

@@ -52,8 +52,14 @@ /*

stuff.placeholders.forEach(function(placeholder) {
var hash = require("crypto").createHash("md5");
hash.update(this.request);
hash.update(placeholder.name);
var ident = "z" + hash.digest("hex");
placeholders[placeholder.name] = ident;
replacer.replace(placeholder.start, placeholder.length, ident);
if(!placeholders[placeholder.name]) {
var hash = require("crypto").createHash("md5");
hash.update(this.options && typeof this.options.context === "string" ?
loaderUtils.stringifyRequest({ context: this.options.context }, this.request) :
this.request);
hash.update(placeholder.name);
var ident = "z" + hash.digest("hex");
placeholders[placeholder.name] = ident;
} else {
var ident = placeholders[placeholder.name];
}
replacer.replace(placeholder.start, placeholder.length, placeholder.prefix + ident);
}, this);

@@ -129,4 +135,8 @@

if(Object.keys(placeholders).length > 0) {
result.push("exports.placeholders = " + JSON.stringify(placeholders) + ";");
}
return "exports = module.exports = require(" + loaderUtils.stringifyRequest(this, require.resolve("./css-base.js")) + ")();\n" +
result.join("\n");
}

@@ -16,5 +16,6 @@ /*

function placeholderMatch(match, name, index) {
function placeholderMatch(match, prefix, name, index) {
this.placeholders.push({
name: name,
prefix: prefix,
start: index,

@@ -51,3 +52,5 @@ length: match.length

// placeholder
"{{([A-Za-z_0-9]+)}}": placeholderMatch
"()\\{\\{([A-Za-z_0-9]+)\\}\\}": placeholderMatch,
"(\\.)\\[([A-Za-z_0-9]+)\\]": placeholderMatch,
"(#)\\[([A-Za-z_0-9]+)\\]": placeholderMatch,
},

@@ -54,0 +57,0 @@ comment: {

{
"name": "css-loader",
"version": "0.10.1",
"version": "0.11.0",
"author": "Tobias Koppers @sokra",

@@ -5,0 +5,0 @@ "description": "css loader module for webpack",

@@ -40,2 +40,34 @@ # css loader for webpack

### Placeholders
(experimental)
Special selectors are automatically replaced with random identifiers, which are exported:
``` css
.[className] { background: red; }
#[someId] { background: green; }
.[className] .[subClass] { color: green; }
#[someId] .[subClass] { color: blue; }
```
is transformed to
``` css
.ze24205081ae540afa51bd4cce768e8b7 { background: red; }
#zdf12049771f7fc796a63a3945da3a66d { background: green; }
.ze24205081ae540afa51bd4cce768e8b7 .z9f634213cd27594c1a13d18554d47a8c { color: green; }
#zdf12049771f7fc796a63a3945da3a66d .z9f634213cd27594c1a13d18554d47a8c { color: blue; }
```
and the identifiers are exported:
``` js
exports.placeholders = {
className: "ze24205081ae540afa51bd4cce768e8b7",
someId: "zdf12049771f7fc796a63a3945da3a66d",
subClass: "z9f634213cd27594c1a13d18554d47a8c"
}
```
### 'Root-relative' urls

@@ -92,3 +124,3 @@

In some cases the structural minification is destructive to the css, so you can disable it with the `disableStructuralMinification` query parameter. `require("css-loader?disableStructuralMinification!./file.css")`
In some cases the minification is destructive to the css, so you can provide some options to it. clean-css is used for minification and you find a [list of options here](https://github.com/jakubpawlowicz/clean-css#how-to-use-clean-css-programmatically). Just provide them as query parameter: i. e. `require("css-loader?-restructuring&compatibility")` to disable restructuring and enable compatibility mode.

@@ -101,6 +133,4 @@ You can also disable or enforce minification with the `minimize` query parameter.

You cannot use minimize with SourceMaps.
## License
MIT (http://www.opensource.org/licenses/mit-license.php)
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc