Giter VIP home page Giter VIP logo

icss-utils's Introduction

CSS Modules Logo

CSS Modules

A CSS Module is a CSS file where all class names and animation names are scoped locally by default. All URLs (url(...)) and @imports are in module request format (./xxx and ../xxx means relative, xxx and xxx/yyy means in modules folder, i.e. in node_modules).

CSS Modules compile to a low-level interchange format called ICSS (or Interoperable CSS) but are written like normal CSS files:

/* style.css */
.className {
  color: green;
}

When importing a CSS Module from a JavaScript Module, it exports an object with all mappings from local names to global names.

import styles from './style.css';

element.innerHTML = '<div class="' + styles.className + '">';

Table of Contents

Why CSS Modules?

  • Local Scope Prevents Clashes: CSS Modules use local scope to avoid style conflicts across different project parts, allowing component-scoped styling.
  • Clear Style Dependencies: Importing styles into their respective components clarifies which styles impact which areas, enhancing code readability and maintenance.
  • Solves Global Scope Problems: CSS Modules prevent the common issue of styles in one file affecting the entire project by localizing styles to specific components.
  • Boosts Reusability and Modularity: CSS Modules allow the same class names in different modules, promoting modular, reusable styling.

icss-utils's People

Contributors

alexander-akait avatar dependabot[bot] avatar eecolor avatar evilebottnawi avatar geelen avatar greenkeeperio-bot avatar jquense avatar markdalgleish avatar mightyaleksey avatar mportuga avatar tomasz-sodzawiczny avatar trysound avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

icss-utils's Issues

TypeError: Cannot read property 'slice' of undefined

ModuleBuildError: Module build failed (from ./node_modules/css-loader/dist/cjs.js):
20:07:31 TypeError: Cannot read property 'slice' of undefined
20:07:31 at css.each.node (/deployer210/workspace/xxx/node_modules/icss-utils/lib/extractICSS.js:23:25)
20:07:31 at Root.each (/deployer210/workspace/xxx/node_modules/postcss-loader/node_modules/postcss/lib/container.js:101:16)
20:07:31 at extractICSS (/deployer210/workspace/xxx/node_modules/icss-utils/lib/extractICSS.js:21:7)
20:07:31 at process (/deployer210/workspace/xxx/node_modules/css-loader/dist/plugins/postcss-icss-parser.js:22:43)
20:07:31 at LazyResult.run (/deployer210/workspace/xxx/node_modules/css-loader/node_modules/postcss/lib/lazy-result.js:295:14)
20:07:31 at LazyResult.asyncTick (/deployer210/workspace/xxx/node_modules/css-loader/node_modules/postcss/lib/lazy-result.js:208:26)
20:07:31 at LazyResult.asyncTick (/deployer210/workspace/xxx/node_modules/css-loader/node_modules/postcss/lib/lazy-result.js:221:14)
20:07:31 at LazyResult.asyncTick (/deployer210/workspace/xxx/node_modules/css-loader/node_modules/postcss/lib/lazy-result.js:221:14)
20:07:31 at processing.Promise.then._this2.processed (/deployer210/workspace/xxx/node_modules/css-loader/node_modules/postcss/lib/lazy-result.js:250:14)
20:07:31 at new Promise ()
20:07:31 at LazyResult.async (/deployer210/workspace/xxx/node_modules/css-loader/node_modules/postcss/lib/lazy-result.js:246:23)
20:07:31 at LazyResult.then (/deployer210/workspace/xxx/node_modules/css-loader/node_modules/postcss/lib/lazy-result.js:127:17)
20:07:31 at Object.loader (/deployer210/workspace/xxx/node_modules/css-loader/dist/index.js:131:6)
20:07:31 at runLoaders (/deployer210/workspace/xxx/node_modules/webpack/lib/NormalModule.js:301:20)
20:07:31 at /deployer210/workspace/xxx/node_modules/loader-runner/lib/LoaderRunner.js:367:11
20:07:31 at /deployer210/workspace/xxx/node_modules/loader-runner/lib/LoaderRunner.js:233:18
20:07:31 at context.callback (/deployer210/workspace/xxx/node_modules/loader-runner/lib/LoaderRunner.js:111:13)
20:07:31 at process.then.catch.error (/deployer210/workspace/xxx/node_modules/css-loader/dist/index.js:258:5)
20:07:31 at

Allow specifying replacements as a callback

Currently, replaceSymbols only accepts a mapping of values. This is problematic because the same value may need to be represented differently in different contexts (reference, and there's no way to do that right now.

An API that would solve this, would be something like:

icssUtils.replaceSymbols(css, (symbol, context) => {
	let mappedSymbol = someMapping[symbol];

	if (context === "decl") {
		return mappedSymbol;
	} else {
		return mappedSymbol.replace(/ /g, ".");
	}
});

https://www.npmjs.com/advisories/1693


┌───────────────┬──────────────────────────────────────────────────────────────┐
│ moderate      │ Regular Expression Denial of Service                         │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Package       │ postcss                                                      │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Patched in    │ >=8.2.10                                                     │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Dependency of │ nuxt                                                         │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Path          │ nuxt > @nuxt/builder > @nuxt/webpack > css-loader >          │
│               │ icss-utils > postcss                                         │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ More info     │ https://www.npmjs.com/advisories/1693                        │
└───────────────┴──────────────────────────────────────────────────────────────┘



┌───────────────┬──────────────────────────────────────────────────────────────┐
│ moderate      │ Regular Expression Denial of Service                         │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Package       │ postcss                                                      │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Patched in    │ >=8.2.10                                                     │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Dependency of │ nuxt                                                         │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Path          │ nuxt > @nuxt/webpack > css-loader > icss-utils > postcss     │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ More info     │ https://www.npmjs.com/advisories/1693                        │
└───────────────┴──────────────────────────────────────────────────────────────┘

┌───────────────┬──────────────────────────────────────────────────────────────┐
│ moderate      │ Regular Expression Denial of Service                         │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Package       │ postcss                                                      │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Patched in    │ >=8.2.10                                                     │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Dependency of │ nuxt                                                         │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Path          │ nuxt > @nuxt/builder > @nuxt/webpack > css-loader >          │
│               │ postcss-modules-local-by-default > icss-utils > postcss      │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ More info     │ https://www.npmjs.com/advisories/1693                        │
└───────────────┴──────────────────────────────────────────────────────────────┘


┌───────────────┬──────────────────────────────────────────────────────────────┐
│ moderate      │ Regular Expression Denial of Service                         │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Package       │ postcss                                                      │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Patched in    │ >=8.2.10                                                     │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Dependency of │ nuxt                                                         │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Path          │ nuxt > @nuxt/webpack > css-loader >                          │
│               │ postcss-modules-local-by-default > icss-utils > postcss      │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ More info     │ https://www.npmjs.com/advisories/1693                        │
└───────────────┴──────────────────────────────────────────────────────────────┘

┌───────────────┬──────────────────────────────────────────────────────────────┐
│ moderate      │ Regular Expression Denial of Service                         │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Package       │ postcss                                                      │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Patched in    │ >=8.2.10                                                     │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Dependency of │ nuxt                                                         │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Path          │ nuxt > @nuxt/builder > @nuxt/webpack > css-loader >          │
│               │ postcss-modules-values > icss-utils > postcss                │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ More info     │ https://www.npmjs.com/advisories/1693                        │
└───────────────┴──────────────────────────────────────────────────────────────┘


┌───────────────┬──────────────────────────────────────────────────────────────┐
│ moderate      │ Regular Expression Denial of Service                         │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Package       │ postcss                                                      │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Patched in    │ >=8.2.10                                                     │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Dependency of │ nuxt                                                         │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Path          │ nuxt > @nuxt/webpack > css-loader > postcss-modules-values > │
│               │ icss-utils > postcss                                         │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ More info     │ https://www.npmjs.com/advisories/1693                        │
└───────────────┴──────────────────────────────────────────────────────────────┘

icss-utils

@geelen I'd like to rename this package to icss-utils and add some stuff to work with postcss/icss ast.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.