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.
- Host: GitHub
- URL: https://github.com/nsaunders/babel-plugin-template-css-minifier
- Owner: nsaunders
- License: mit
- Created: 2023-01-27T14:55:07.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2023-10-06T20:41:16.000Z (over 2 years ago)
- Last Synced: 2025-08-21T11:36:50.832Z (10 months ago)
- Language: JavaScript
- Size: 152 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# babel-plugin-template-css-minifier

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.