An open API service indexing awesome lists of open source software.

https://github.com/nsaunders/babel-plugin-template-css-minifier

Minifies CSS embedded in template literals.
https://github.com/nsaunders/babel-plugin-template-css-minifier

Last synced: about 2 months ago
JSON representation

Minifies CSS embedded in template literals.

Awesome Lists containing this project

README

          

# babel-plugin-template-css-minifier Build status Latest Release License

This [Babel](http://babeljs.io) plugin minifies CSS code embedded within a [template literal](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals). Simply tag the template literal with a leading `/* css */` comment to activate the plugin.

## Example

**Input**
```javascript
const css = /*css*/`
body {
height: 100%;
}
`;
```
**Output**
```javascript
const css = /*css*/`body{height: 100%;}`;
```

## Configuration

The plugin doesn't require any configuration in itself. Your `.babelrc` file can be as simple as this:

**.babelrc**
```json
{ "plugins": ["babel-plugin-template-css-minifier"] }
```

Due to Babel's [first-to-last plugin ordering](https://babeljs.io/docs/en/plugins/#plugin-ordering), this plugin should be placed at or near the beginning of the list of plugins so that it runs before template literals are transformed by another plugin.