# @jkroepke/webpack-file-preprocessor-plugin

> An updated version of a lightweight yet generic webpack plugin for pre-processing assets before emitting.

Latest version **2.0.1** (published 2021-06-25) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install @jkroepke/webpack-file-preprocessor-plugin
pnpm add @jkroepke/webpack-file-preprocessor-plugin
yarn add @jkroepke/webpack-file-preprocessor-plugin
bun add @jkroepke/webpack-file-preprocessor-plugin
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 2.0.1 |
| Published | 2021-06-25 |
| First published | 2019-10-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=10.13 |
| Dependencies | 1 |
| Unpacked size | 6.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Jan-Otto Kröpke |
| Maintainers | jkroepke |
| Keywords | javascript, webpack, file-loader, preprocessor, plugin, file |

## Links

- npm: https://www.npmjs.com/package/@jkroepke/webpack-file-preprocessor-plugin
- Repository: https://github.com/jkroepke/webpack-file-preprocessor-plugin
- Homepage: https://github.com/jkroepke/webpack-file-preprocessor-plugin#readme
- Issues: https://github.com/jkroepke/webpack-file-preprocessor-plugin/issues
- npm.io page: https://npm.io/package/@jkroepke/webpack-file-preprocessor-plugin

## Dependencies (1)

- [webpack-sources](https://npm.io/package/webpack-sources.md) ^2.3

## Alternatives

- [unionfs](https://npm.io/package/unionfs.md) — 2.2M weekly downloads
- [path-starts-with](https://npm.io/package/path-starts-with.md) — 35.9K weekly downloads
- [redzip](https://npm.io/package/redzip.md) — 1.2K weekly downloads
- [vscode-anymatch](https://npm.io/package/vscode-anymatch.md) — 848 weekly downloads
- [@ledgerhq/coin-filecoin](https://npm.io/package/@ledgerhq/coin-filecoin.md) — 793 weekly downloads

## Recent versions

- 2.0.1 (latest) — 2021-06-25
- 2.0.0 — 2020-11-18
- 1.0.2 — 2019-10-13
- 1.0.1 — 2019-10-13
- 1.0.0 — 2019-10-13
- 1.0.0-beta.2 — 2019-10-13
- 1.0.0-beta.1 — 2019-10-13

## README

# Webpack File Preprocessor Plugin
[![NPM Version](https://img.shields.io/npm/v/@jkroepke/webpack-file-preprocessor-plugin.svg?style=flat-square)](https://www.npmjs.com/package/@jkroepke/webpack-file-preprocessor-plugin)
[![NPM Downloads](https://img.shields.io/npm/dt/@jkroepke/webpack-file-preprocessor-plugin.svg?style=flat-square)](https://www.npmjs.com/package/@jkroepke/webpack-file-preprocessor-plugin)
[![Actions Status](https://github.com/jkroepke/webpack-file-preprocessor-plugin/workflows/CI/badge.svg)](https://github.com/jkroepke/webpack-file-preprocessor-plugin/actions)
[![Maintainability](https://api.codeclimate.com/v1/badges/88c15c54ca6e8dc9ccdc/maintainability)](https://codeclimate.com/github/jkroepke/webpack-file-preprocessor-plugin/maintainability)

A lightweight yet generic webpack plugin for pre-processing assets before emitting.

## Installation

```bash
# Using npm
$ npm install webpack-file-preprocessor-plugin --save-dev

# Using Yarn
$ yarn add webpack-file-preprocessor-plugin --dev
```

## Usage

This example demonstrates how to use this plugin to minify the html assets loaded using `file-loader`.

```javascript
const webpack = require('webpack');
const WebpackFilePreprocessorPlugin = require('webpack-file-preprocessor-plugin');
const minifyHtml = require('html-minifier').minify;

module.exports = {
    entry: {
        app: './index.js'
    },
    output: {
        path: './public/dist',
        publicPath: '/dist/',
        filename: '[name].bundle.js'
    },
    module: {
        rules: [
            {
                test: /\.html$/,
                use: {
                    loader: 'file-loader', 
                    options: {
                    name: 'tmpl/[hash].html'
                    }
                }
            }
        ]
    },
    plugins: [
        new WebpackFilePreprocessorPlugin({
            // Prints processed assets if set to true (default: false)
            debug: true,
            // RegExp pattern to filter assets for pre-processing.
            pattern: /\.html$/,
            // Do your processing in this process function.
            process: (source) => minifyHtml(source.toString())
        })
    ]
};
```

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