Post CSS Module #45 Flashcards
What is PostCSS?
PostCSS is a tool that allows developers to write CSS pre-processors or post-processors, called plugins.
What is the main benefit of using PostCSS?
The main benefit PostCSS provides over CSS preprocessors like Sass or Less is the ability to choose your own path, and cherry-pick the features you need, adding new capabilities at the same time. Sass or Less are “fixed”, you get lots of features which you might or might not use, and you cannot extend them
How can you install PostCSS CLI
npm install -g postcss-cli
Using the PostCSS cli how can you run the autoprefixer plugin on your css files?
postcss –use autoprefixer -o main.css css/*.css
What’s the reason for running autoprefixer in the first place?
Autoprefixer parses your CSS and determines if some rules need a vendor prefix.
What are CSS modules?
CSS Modules are not part of the CSS standard, but they are a build step process to have scoped selectors.
https://css-tricks.com/css-modules-part-1-need/
CSS files in which all class names and animation names are scoped locally by default.
Example:
<h1>An example heading</h1>
.title { background-color: red; }
CSS Modules takes a different approach. Instead of writing plain HTML, we need to write all of our markup in a JavaScript file, like index.js. Here’s an example of how that might work (we’ll take a look at a more realistic example later):
CSS Module in JS: element.innerHTML = `<h1 class="${styles.title}"> An example heading </h1>`;