# babel-plugin-csstag

> Babel plugin for compiling CSS Modules in csstag's tagged templates to actual styles for production.

Latest version **0.2.1** (published 2020-04-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install babel-plugin-csstag
pnpm add babel-plugin-csstag
yarn add babel-plugin-csstag
bun add babel-plugin-csstag
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.1 |
| Published | 2020-04-20 |
| First published | 2019-02-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 18 |
| Author | Danil Semelenov |
| Maintainers | sgtpep |
| Keywords | babel, babel-plugin, browser, css, css-modules, esm, postcss, tagged-template, tagged-template-literal, template-literal |

## Links

- npm: https://www.npmjs.com/package/babel-plugin-csstag
- Repository: https://github.com/sgtpep/csstag
- Homepage: https://github.com/sgtpep/csstag/tree/master/babel-plugin-csstag
- Issues: https://github.com/sgtpep/csstag/issues
- npm.io page: https://npm.io/package/babel-plugin-csstag

## Dependencies (2)

- [csstag](https://npm.io/package/csstag.md) 0.x.x
- [clean-css](https://npm.io/package/clean-css.md) ^4.2.1

## Alternatives

- [style-dictionary](https://npm.io/package/style-dictionary.md) — 2.0M weekly downloads
- [postcss-merge-idents](https://npm.io/package/postcss-merge-idents.md) — 1.7M weekly downloads
- [@fontsource/noto-sans](https://npm.io/package/@fontsource/noto-sans.md) — 93.0K weekly downloads
- [uglifycss](https://npm.io/package/uglifycss.md) — 71.6K weekly downloads
- [mat4-interpolate](https://npm.io/package/mat4-interpolate.md) — 23.3K weekly downloads

## Recent versions

- 0.2.1 (latest) — 2020-04-20
- 0.2.0 — 2019-02-08
- 0.1.1 — 2019-02-06
- 0.1.0 — 2019-02-06

## README

# babel-plugin-csstag

[![Build Status](https://travis-ci.org/sgtpep/csstag.svg?branch=master)](https://travis-ci.org/sgtpep/csstag)

[Babel](https://babeljs.io/) plugin for compiling CSS Modules in [csstag](https://github.com/sgtpep/csstag)'s tagged templates to actual styles for production.

You can find examples for [webpack](https://webpack.js.org/) and [rollup](https://rollupjs.org/) here: https://github.com/sgtpep/csstag/tree/master/babel-plugin-csstag/examples.

## Usage with webpack

In `webpack.config.js` override imports of `csstag` with a replacement stub script `babel-plugin-csstag/csstag`:

```javascript
...
  resolve: {
    alias: {
      csstag: 'babel-plugin-csstag/csstag',
    },
  },
...
```

In `webpack.config.js` enable a Babel plugin `babel-plugin-csstag`:

```javascript
import babel from 'rollup-plugin-babel';
...
  module: {
    rules: [
      ...
      {
        exclude: /\/node_modules\//,
        test: /\.js$/,
        use: {
          loader: 'babel-loader',
          options: {
            plugins: ['babel-plugin-csstag'],
            presets: ['@babel/env'],
          },
        },
      },
      ...
    ],
  },
...
```

## Usage with rollup

In `rollup.config.js` override imports of `csstag` with a replacement stub script `node_modules/babel-plugin-csstag/csstag.js` (replace an object key `csstag` with an exact import path that you used in your app, which may also be `'./node_modules/csstag/index.min.js'`):

```javascript
import alias from 'rollup-plugin-alias';
...
  plugins: [
    ...
    alias({
      csstag: 'node_modules/babel-plugin-csstag/csstag.js',
    }),
    ...
  ],
...
```

In `rollup.config.js` enable a Babel plugin `babel-plugin-csstag`:

```javascript
import babel from 'rollup-plugin-babel';
...
  plugins: {
    ...
    babel({
      plugins: ['babel-plugin-csstag'],
      presets: ['@babel/env'],
    }),
    ...
  },
...
```

## Options

To pass options add an object with them to your Babel config:

```javascript
...
plugins: [
  ...
  ['babel-plugin-csstag', { tag: 'custom' }],
  ...
],
...
```

- `tag`: A name of a tag function if you used something other than `css` (default: `css`).

All other provided options will be passed to `csstag` as is. They should be the same as ones you used in runtime if any.

---
_Source: https://npm.io/package/babel-plugin-csstag · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
