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

css-modules-require-hook

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

css-modules-require-hook - npm Package Compare versions

Comparing version 1.0.5 to 1.0.6

5

dist/hook.js
/**
* @param {function} compile
* @param {string} extension
*/

@@ -11,4 +12,4 @@ 'use strict';

function attachHook(compile) {
require.extensions['.css'] = function hook(m, filename) {
function attachHook(compile, extension) {
require.extensions[extension] = function hook(m, filename) {
var tokens = compile(filename);

@@ -15,0 +16,0 @@ return m._compile('module.exports = ' + JSON.stringify(tokens), filename);

14

dist/index.js

@@ -67,2 +67,3 @@ 'use strict';

* @param {function} opts.generateScopedName
* @param {function} opts.preprocessCss
* @param {function} opts.processCss

@@ -72,2 +73,3 @@ * @param {string} opts.rootDir

* @param {array} opts.use
* @param {array} opts.extensions
*/

@@ -82,2 +84,3 @@

preProcess = (0, _utility.get)('preprocessCss', null, 'function', opts) || _lodashIdentity2['default'];
postProcess = (0, _utility.get)('processCss', null, 'function', opts) || null;

@@ -103,2 +106,11 @@ rootDir = (0, _utility.get)('rootDir', ['root', 'd'], 'string', opts) || process.cwd();

plugins.push(generateScopedName ? new _postcssModulesScope2['default']({ generateScopedName: opts.generateScopedName }) : _postcssModulesScope2['default']);
var extraExtensions = (0, _utility.get)('extensions', null, 'array', opts);
if (extraExtensions) {
extraExtensions.forEach(function (extension) {
(0, _hook2['default'])(function (filename) {
return fetch(filename, filename);
}, extension);
});
}
}

@@ -146,3 +158,3 @@

return fetch(filename, filename);
});
}, '.css');
module.exports = exports['default'];
{
"name": "css-modules-require-hook",
"version": "1.0.5",
"version": "1.0.6",
"description": "A require hook to compile CSS Modules on the fly",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -35,2 +35,3 @@ css-modules-require-hook

* `function` **generateScopedName** — short alias for the [postcss-modules-scope](https://github.com/css-modules/postcss-modules-scope) plugin's option. Helps you to specify the custom way to build generic names for the class selectors.
* `function` **preprocessCss** — in rare cases you may want to precompile styles, before they will be passed to the postcss pipeline. You should use **synchronous** transformations, since `require` function is synchronous.
* `function` **processCss** — in rare cases you may want to get compiled styles in runtime, so providing this option helps.

@@ -40,2 +41,3 @@ * `string` **rootDir** — absolute path to the project directory. Providing this will result in better generated class names. It can be obligatory, if you run require hook and build tools (like [css-modulesify](https://github.com/css-modules/css-modulesify)) from different working directories.

* `array` **use** — custom subset of postcss plugins.
* `array` **extensions** — attach the hook to additional file extensions (for example `['.scss']`).

@@ -42,0 +44,0 @@ ### Examples

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