# js-inline-css-webpack-plugin

> A webpack plugin for convert external stylesheet to embedded into js stylesheet

Latest version **1.1.1** (published 2019-08-29) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.1 |
| Published | 2019-08-29 |
| First published | 2019-08-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 20 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Denis Artyuhovich |
| Maintainers | denisby |
| Keywords | js, inline, css, webpack, plugin |

## Links

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

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 1.1.1 (latest) — 2019-08-29
- 1.1.0 — 2019-08-29
- 1.0.0 — 2019-08-27

## README

# js-inline-css-webpack-plugin
[![MIT Licence](https://badges.frapsoft.com/os/mit/mit.svg?v=103)](https://opensource.org/licenses/mit-license.php)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/Runjuu/js-inline-css-webpack-plugin/pulls)
[![Total downloads](https://img.shields.io/npm/dm/js-inline-css-webpack-plugin.svg)](https://www.npmjs.com/package/js-inline-css-webpack-plugin)
[![npm version](https://badge.fury.io/js/js-inline-css-webpack-plugin.svg)](https://www.npmjs.com/package/js-inline-css-webpack-plugin)

This plugin inspired by **html-inline-css-webpack-plugin** but instead of injecting
directly to the html, it injects css into js (useful for libraries and testing purposes)
like: 
```
document.body.appendChild(nodeWithStyles);
```

Require [mini-css-extract-plugin](https://github.com/webpack-contrib/mini-css-extract-plugin).

## Install
#### NPM
```bash
npm i js-inline-css-webpack-plugin -D
```
#### Yarn
```bash
yarn add js-inline-css-webpack-plugin -D
```

## Minimal example
```js
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const HtmlWebpackPlugin = require('html-webpack-plugin');
const JsInlineCssWebpackPlugin = require("js-inline-css-webpack-plugin").default;

module.exports = {
  plugins: [
    new MiniCssExtractPlugin({
      filename: "[name].css",
      chunkFilename: "[id].css"
    }),
    new HtmlWebpackPlugin(),
    new JsInlineCssWebpackPlugin(),
  ],
  module: {
    rules: [
      {
        test: /\.css$/,
        use: [
          MiniCssExtractPlugin.loader,
          "css-loader"
        ]
      }
    ]
  }
}
```

## Config
```typescript
interface Config {
  filter?(fileName: string): boolean
  leaveCSSFile?: boolean
}
```

### filter(optional)
```typescript
filter?(fileName: string): boolean
```
Return `true` to make current file internal, otherwise ignore current file.
##### example
```typescript
...
  new JsInlineCssWebpackPlugin({
    filter(fileName) {
      return fileName.includes('main');
    },
  }),
...
```

### leaveCSSFile(optional)
if `true`, it will leave CSS files where they are when inlining

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