@epegzz/sass-vars-loader
Advanced tools
Comparing version 3.0.0 to 3.2.0
@@ -12,8 +12,9 @@ 'use strict'; | ||
var files = options.files || []; | ||
var syntax = options.syntax || 'scss'; | ||
(0, _watchFilesForChanges2.default)(this, files); | ||
var vars = _extends({}, options.vars, (0, _readVarsFromJSONFiles2.default)(files), (0, _readVarsFromJavascriptFiles2.default)(files)); | ||
var vars = _extends({}, (0, _readVarsFromJSONFiles2.default)(files), (0, _readVarsFromJavascriptFiles2.default)(files), options.vars); | ||
var sassVarsString = (0, _convertJsToSass2.default)(vars); | ||
var sassVarsString = (0, _convertJsToSass2.default)(vars, syntax); | ||
@@ -20,0 +21,0 @@ return `${sassVarsString}${content}`; |
'use strict'; | ||
exports.__esModule = true; | ||
function convertJsToSass(obj, isNested) { | ||
function convertJsToSass(obj) { | ||
var syntax = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'scss'; | ||
var isNested = arguments[2]; | ||
var prefix = isNested ? '' : '$'; | ||
var suffix = isNested ? ',\n' : ';\n'; | ||
var lastItemSuffix = isNested ? '' : ';\n'; | ||
var suffix = isNested ? ', ' : syntax === 'sass' ? '\n' : ';\n'; | ||
var lastItemSuffix = isNested ? '' : syntax === 'sass' ? '\n' : ';\n'; | ||
var keys = Object.keys(obj); | ||
var lines = keys.map(function (key) { | ||
return `${prefix}${key}:${formatValue(obj[key])}`; | ||
return `${prefix}${key}: ${formatValue(obj[key], syntax)}`; | ||
}); | ||
@@ -17,3 +20,3 @@ | ||
function formatValue(value) { | ||
function formatValue(value, syntax) { | ||
if (value instanceof Array) { | ||
@@ -24,3 +27,3 @@ return `(${value.map(formatValue).join(', ')})`; | ||
if (typeof value === 'object') { | ||
return `(\n${convertJsToSass(value, true)}\n)`; | ||
return `(${convertJsToSass(value, syntax, true)})`; | ||
} | ||
@@ -27,0 +30,0 @@ |
{ | ||
"name": "@epegzz/sass-vars-loader", | ||
"version": "3.0.0", | ||
"version": "3.2.0", | ||
"author": "Daniel Schäfer <epegzz@gmail.com>", | ||
@@ -5,0 +5,0 @@ "description": |
<h1 align="center">Sass Vars Loader</h1> | ||
<h3 align="center">Use vars in your SCSS files provided via Webpack</h3> | ||
<h3 align="center">Use external vars in your SCSS files</h3> | ||
<p align="center"> | ||
<a href="https://travis-ci.org/epegzz/sass-vars-loader"> | ||
<a target="_blank" href="https://travis-ci.org/epegzz/sass-vars-loader"> | ||
<img alt="Travis" src="https://img.shields.io/travis/epegzz/sass-vars-loader.svg?style=flat-square"> | ||
</a> | ||
<a href="https://codecov.io/gh/epegzz/sass-vars-loader"> | ||
<a target="_blank" href="https://codeclimate.com/github/epegzz/sass-vars-loader/maintainability"> | ||
<img alt="Maintainability" src="https://img.shields.io/codeclimate/maintainability/epegzz/sass-vars-loader.svg?style=flat-square"> | ||
</a> | ||
<a target="_blank" href="https://codecov.io/gh/epegzz/sass-vars-loader"> | ||
<img alt="Codecov" src="https://img.shields.io/codecov/c/github/epegzz/sass-vars-loader.svg?style=flat-square"> | ||
</a> | ||
<a href="https://www.npmjs.com/package/@epegzz/sass-vars-loader"> | ||
<a target="_blank" href="https://www.npmjs.com/package/@epegzz/sass-vars-loader"> | ||
<img alt="npm version" src="https://img.shields.io/npm/v/@epegzz/sass-vars-loader.svg?style=flat-square"> | ||
</a> | ||
<a href="https://www.npmjs.com/package/@epegzz/sass-vars-loader"> | ||
<img alt="npm version" src="https://img.shields.io/npm/dm/@epegzz/sass-vars-loader.svg?style=flat-square"> | ||
<a target="_blank" href="https://www.npmjs.com/package/@epegzz/sass-vars-loader"> | ||
<img alt="npm installs" src="https://img.shields.io/npm/dm/@epegzz/sass-vars-loader.svg?style=flat-square"> | ||
</a> | ||
<a target="_blank" href="https://david-dm.org/epegzz/sass-vars-loader"> | ||
<img alt="dependencies" src="https://img.shields.io/david/epegzz/sass-vars-loader.svg?style=flat-square"> | ||
</a> | ||
</p> | ||
@@ -29,6 +35,12 @@ | ||
using npm | ||
```sh | ||
npm install @epegzz/sass-vars-loader --save-dev | ||
``` | ||
using yarn | ||
```sh | ||
yarn add @epegzz/sass-vars-loader --dev | ||
``` | ||
## Usage | ||
@@ -72,2 +84,3 @@ | ||
{ loader: "@epegzz/sass-vars-loader", options: { | ||
syntax: 'scss', | ||
// Option 1) Specify vars here | ||
@@ -128,2 +141,3 @@ vars: { | ||
{ loader: "@epegzz/sass-vars-loader", options: { | ||
syntax: 'scss', | ||
files: [ | ||
@@ -185,2 +199,3 @@ // Option 2) Load vars from JSON file | ||
{ loader: "@epegzz/sass-vars-loader", options: { | ||
syntax: 'scss', | ||
files: [ | ||
@@ -187,0 +202,0 @@ // Option 3) Load vars from Javascript file |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
135670
74
243
0
9