css-js-loader
Advanced tools
Comparing version 0.4.0 to 0.4.1
24
index.js
@@ -8,3 +8,3 @@ var defaults = require('lodash/defaults'); | ||
var loaderUtils = require('loader-utils'); | ||
var dangerousStyleValue = require('react-dom/lib/dangerousStyleValue'); | ||
var dangerousStyleValue = require('./internal/dangerousStyleValue'); | ||
var hyphenateStyleName = require('fbjs/lib/hyphenateStyleName'); | ||
@@ -14,7 +14,7 @@ | ||
return pretty ? Array(depth).join(' ') : ''; | ||
}; | ||
} | ||
function space(pretty) { | ||
return pretty ? ' ' : ''; | ||
}; | ||
} | ||
@@ -49,3 +49,5 @@ function line(pretty) { | ||
css += indent(pretty, indentLevel) + hyphenateStyleName(name) + ':' + space(pretty); | ||
css += indent(pretty, indentLevel) + | ||
hyphenateStyleName(name) + ':' + | ||
space(pretty); | ||
css += dangerousStyleValue(name, value) + ';' + line(pretty); | ||
@@ -60,3 +62,4 @@ } else { | ||
// block to the markup. | ||
css += indent(pretty, indentLevel) + name + space(pretty) + '{' + line(pretty); | ||
css += indent(pretty, indentLevel) + name + space(pretty) + '{' + | ||
line(pretty); | ||
indentLevel += 1; | ||
@@ -98,11 +101,10 @@ } | ||
config = defaults( | ||
loaderUtils.getLoaderConfig(this, 'jsCssLoader'), | ||
var config = defaults( | ||
loaderUtils.getOptions(this), | ||
{pretty: process.env.NODE_ENV !== 'production'} | ||
); | ||
var styles = this.exec(content, this.resourcePath); | ||
var styles = typeof content === 'object' ? content : | ||
this.exec(content, this.resourcePath); | ||
var css = ''; | ||
if (styles.__esModule) { | ||
@@ -131,3 +133,3 @@ // When using Babel, css classes can be defined as named es6 exports. | ||
omit(styles, 'default'), | ||
function (value, key) { | ||
function(value, key) { | ||
return '.' + key; | ||
@@ -134,0 +136,0 @@ } |
{ | ||
"name": "css-js-loader", | ||
"version": "0.4.0", | ||
"version": "0.4.1", | ||
"description": "", | ||
"main": "index.js", | ||
"repository": "metalabdesign/css-js-loader", | ||
"scripts": { | ||
@@ -13,16 +14,10 @@ "test": "npm run lint", | ||
"dependencies": { | ||
"fbjs": "^0.8.8", | ||
"loader-utils": "^0.2.16", | ||
"lodash": "^4.17.4", | ||
"react-dom": "^15.4.2" | ||
"fbjs": "^0.8.16", | ||
"loader-utils": "^1.1.0", | ||
"lodash": "^4.17.4" | ||
}, | ||
"devDependencies": { | ||
"eslint": "^2.10.2", | ||
"eslint-config-metalab": "^4.0.1", | ||
"eslint-import-resolver-babel-module": "^2.0.1", | ||
"eslint-plugin-filenames": "^0.2.0", | ||
"eslint-plugin-import": "^1.15.0", | ||
"eslint-plugin-lodash-fp": "^1.2.0", | ||
"eslint-plugin-react": "^5.1.1" | ||
"eslint": "^4.9.0", | ||
"eslint-config-metalab": "^7.0.1" | ||
} | ||
} |
@@ -16,3 +16,3 @@ # css-js-loader | ||
```sh | ||
yarn add css-js-loader | ||
npm install css-js-loader value-loader | ||
``` | ||
@@ -31,3 +31,3 @@ | ||
test: /\.css\.js$/, | ||
loader: 'css-js-loader', | ||
loaders: ['css-js-loader', 'value-loader'], | ||
}], | ||
@@ -38,5 +38,7 @@ }, | ||
NOTE: You don't need to chain with [value-loader] per-se, but doing so gives you caching, nested dependency monitoring/reloading and the ability to use webpack's tree-shaking abilities. | ||
## Writing JS Styles | ||
`css-js-loader` converts JS modules to CSS markup at runtime. | ||
`css-js-loader` converts JS modules to CSS markup at runtime. | ||
@@ -110,1 +112,2 @@ A `.css.js` file: | ||
[CSS Modules]: https://github.com/webpack-contrib/css-loader#css-modules | ||
[value-loader]: https://www.npmjs.com/package/value-loader |
@@ -0,1 +1,2 @@ | ||
/* global __WRAPPED__ __CONTEXT__ __IDENT_NAME__ */ | ||
var Module = require('module'); | ||
@@ -2,0 +3,0 @@ |
/* eslint-disable guard-for-in */ | ||
var path = require('path'); | ||
var getLocalIdent = require('css-loader/lib/getLocalIdent'); | ||
@@ -5,0 +4,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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
3
2
11
275
110
13390
1
+ Addedbig.js@5.2.2(transitive)
+ Addedemojis-list@3.0.0(transitive)
+ Addedjson5@1.0.2(transitive)
+ Addedloader-utils@1.4.2(transitive)
+ Addedminimist@1.2.8(transitive)
- Removedreact-dom@^15.4.2
- Removedbig.js@3.2.0(transitive)
- Removedcreate-react-class@15.7.0(transitive)
- Removedemojis-list@2.1.0(transitive)
- Removedjson5@0.5.1(transitive)
- Removedloader-utils@0.2.17(transitive)
- Removedprop-types@15.8.1(transitive)
- Removedreact@15.7.0(transitive)
- Removedreact-dom@15.7.0(transitive)
- Removedreact-is@16.13.1(transitive)
Updatedfbjs@^0.8.16
Updatedloader-utils@^1.1.0