# atomic-css-webpack-plugin

> Atomized CSS development enhancement plugin

Latest version **0.2.0** (published 2021-11-17) · ISC license · 0 weekly downloads

## Install

```sh
npm install atomic-css-webpack-plugin
pnpm add atomic-css-webpack-plugin
yarn add atomic-css-webpack-plugin
bun add atomic-css-webpack-plugin
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.0 |
| Published | 2021-11-17 |
| First published | 2021-10-24 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 20.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Maintainers | peteryuan |
| Keywords | Atomized, CSS, Webpack Plugin |

## Links

- npm: https://www.npmjs.com/package/atomic-css-webpack-plugin
- Repository: https://github.com/GitHubJiKe/atomic-css-webpack-plugin
- Homepage: https://github.com/GitHubJiKe/atomic-css-webpack-plugin#readme
- Issues: https://github.com/GitHubJiKe/atomic-css-webpack-plugin/issues
- npm.io page: https://npm.io/package/atomic-css-webpack-plugin

## 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.0 (latest) — 2021-11-17
- 0.1.9 — 2021-11-17
- 0.1.8 — 2021-11-05
- 0.1.7 — 2021-11-04
- 0.1.6 — 2021-11-04
- 0.1.5 — 2021-11-03
- 0.1.4 — 2021-11-03
- 0.1.3 — 2021-11-02
- 0.1.2 — 2021-11-02
- 0.1.1 — 2021-11-02
- 0.1.0 — 2021-10-31
- 0.0.9 — 2021-10-31
- 0.0.8 — 2021-10-29
- 0.0.7 — 2021-10-27
- 0.0.6 — 2021-10-26
- … 5 more at https://npm.io/package/atomic-css-webpack-plugin/versions

## README

# Atomic CSS Webpack Plugin

 <a href='https://www.npmjs.com/package/atomic-css-webpack-plugin' style='margin: 0 0.2rem;' />
    <img src='https://img.shields.io/npm/v/atomic-css-webpack-plugin' alt='npm version' height='18'>
  </a>

**[Chinese Docs](./README.zh.md)**

> **Atomized CSS** development enhancement plugin. Inspired by [Tailwindcss](https://www.tailwindcss.cn/).

- Framework independent
- Support completely custom configuration (now you have to have one config file, plugin will not support default config anymore)
- Flexible naming rules (it's better than [Tailwindcss](https://www.tailwindcss.cn/) in this way)
- On-demanded usage(you can custom your config file follow your need, you won't get one redundant css classes file)
- Support utils to custom css utils
- Support `!important` (it's better than [Tailwindcss](https://www.tailwindcss.cn/))
- with [purgecss](https://purgecss.com/) to remove useless css content

With VSCode Plugin [「IntelliSense for CSS class names in HTML」](https://marketplace.visualstudio.com/items?itemName=Zignd.html-css-class-completion)experience better.

## demo

[atomic css webpack plugin](https://atomic-css-webpack-plugin.vercel.app/)

## useage

`npm i -D atomic-css-webpack-plugin@latest`

### example

```javascript
const path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const AtomicCSSWebpackPlugin = require("atomic-css-webpack-plugin");

module.exports = {
  mode: "development",
  entry: path.resolve(__dirname, "./app.js"),
  output: {
    path: path.resolve(__dirname, "dist"),
    filename: "bundle.[hash].js",
    clean: true
  },
  plugins: [
    new HtmlWebpackPlugin({
      title: "Atomic CSS Webpack Plugin",
      minify: "auto"
    }),
    new AtomicCSSWebpackPlugin({
      config: path.resolve(__dirname, "./myconfig.js")
    }) // you can use your customized config file or you just use the default config
  ]
};
```

### plugin config

| Field     | Explain                                                                     | Type               | Default | Required |
| --------- | --------------------------------------------------------------------------- | ------------------ | ------- | -------- |
| config    | Config file path                                                            | string             | ''      | true     |
| versoin   | webpack big version                                                         | string/number 5 or 4 | '4'     | false     |
| assets    | Css asset output path (if you set 'css', atomic.css will output in css dir) | string             | ''      | false    |
| publicPath | Css asset output publicPath | string             | '/'      | false    |
| importWay | use link or style tag import css                                            | 'link'/'inline'    | 'inline'  | false    |
| parser    | customer parse logic for your own config file                               | function(config){} | null      | false    |

## config rules

> config file is one js module object, just like below:

```javascript
module.exports = {
  atomic: {
    text: {
      // className prefix
      color: {
        // css property
        "-white": "#fff" // className postfix : css value
      },
      "text-align": {
        "-center!": "center" // postfix with `!` you will get `!important` class
      }
    },
    p: {
      "padding-left": {
        "l-10": "10px"
      },
      "padding-right": {
        "r-10": "10px"
      },
      "padding-left$padding-right": {
        // if you want to set more than one property, use `$` to split
        "x-10": "10px"
      }
    }
  },
  utils: {
    link: {
      css: {
        color: "blue",
        cursor: "pointer"
      },
      actions: {
        hover: {
          color: "red"
        }
      }
    }
  }
};
```

> with above config file, you will get below css classes:

```css
.text-white {
  color: #fff;
}
.text-center {
  text-align: center !important;
}
.pl-10 {
  padding-left: 10px;
}
.pr-10 {
  padding-right: 10px;
}
.px-10 {
  padding-left: 10px;
  padding-right: 10px;
}
.link {
  color: blue;
  cursor: pointer;
}
.link:hover {
  color: red;
}
```

> but if you only used `text-center`, finally you will get css file as below

```css
.text-center {
  text-align: center !important;
}
```

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