ignore-styles
Advanced tools
Comparing version 1.2.0 to 2.0.0
@@ -8,2 +8,7 @@ export const DEFAULT_EXTENSIONS = [ | ||
'.less', | ||
'.gif', | ||
'.jpeg', | ||
'.jpg', | ||
'.png', | ||
'.svg', | ||
] | ||
@@ -10,0 +15,0 @@ |
@@ -7,3 +7,3 @@ 'use strict'; | ||
exports.default = register; | ||
var DEFAULT_EXTENSIONS = exports.DEFAULT_EXTENSIONS = ['.css', '.scss', '.sass', '.stylus', '.styl', '.less']; | ||
var DEFAULT_EXTENSIONS = exports.DEFAULT_EXTENSIONS = ['.css', '.scss', '.sass', '.stylus', '.styl', '.less', '.gif', '.jpeg', '.jpg', '.png', '.svg']; | ||
@@ -10,0 +10,0 @@ var oldHandlers = exports.oldHandlers = {}; |
{ | ||
"name": "ignore-styles", | ||
"version": "1.2.0", | ||
"version": "2.0.0", | ||
"description": "Ignore imported style files when running in Node", | ||
@@ -5,0 +5,0 @@ "main": "lib/ignore-styles.js", |
@@ -24,2 +24,6 @@ # ignore-styles | ||
## Installation | ||
$ npm install --save-dev ignore-styles | ||
## More Examples | ||
@@ -34,3 +38,3 @@ | ||
```js | ||
import 'ignore-styles' | ||
import 'ignore-styles' | ||
``` | ||
@@ -65,5 +69,9 @@ | ||
import register from 'ignore-styles' | ||
register(undefined, () => {styleName: 'fake_class_name'}) | ||
register(undefined, () => ({styleName: 'fake_class_name'})) | ||
``` | ||
The first argument to `register` is the list of extensions to handle. Leaving it | ||
undefined, as above, uses the default list. The handler function receives two arguments, `module` and `filename`, directly | ||
from Node. | ||
Why is this useful? One example is when using something like | ||
@@ -74,2 +82,16 @@ [react-css-modules][react-css-modules]. You need the style imports to actually | ||
Another use case would be to simply return the filename of an image so that it | ||
can be verified in unit tests: | ||
```js | ||
register(undefined, (module, filename) => { | ||
if (_.some(['.png', '.jpg'], ext => filename.endsWith(ext))) { | ||
return path.basename(filename) | ||
} | ||
}) | ||
``` | ||
If the filename ends in '.png' or '.jpg', then the basename of the file is | ||
returned as the value of the module on import. | ||
## License | ||
@@ -76,0 +98,0 @@ |
Sorry, the diff of this file is not supported yet
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
12068
14
111
109