# webpack-partial

> Webpack partials.

Latest version **2.2.0** (published 2018-01-13) · CC0-1.0 license · 0 weekly downloads

## Install

```sh
npm install webpack-partial
pnpm add webpack-partial
yarn add webpack-partial
bun add webpack-partial
```

## 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 | 2.2.0 |
| Published | 2018-01-13 |
| First published | 2015-08-18 |
| Weekly downloads | 0 |
| License | CC0-1.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 35 |
| Author | Izaak Schroeder |
| Maintainers | izaakschroeder |
| Keywords | webpack, partial, include |

## Links

- npm: https://www.npmjs.com/package/webpack-partial
- Repository: https://github.com/izaakschroeder/webpack-partial
- Homepage: https://github.com/izaakschroeder/webpack-partial#readme
- Issues: https://github.com/izaakschroeder/webpack-partial/issues
- npm.io page: https://npm.io/package/webpack-partial

## Dependencies (1)

- [lodash](https://npm.io/package/lodash.md) ^4.12.0

## Alternatives

- [raw-loader](https://npm.io/package/raw-loader.md) — 4.3M weekly downloads
- [plop](https://npm.io/package/plop.md) — 1.4M weekly downloads
- [webpack-deadcode-plugin](https://npm.io/package/webpack-deadcode-plugin.md) — 80.3K weekly downloads
- [@storybook/preact-vite](https://npm.io/package/@storybook/preact-vite.md) — 54.2K weekly downloads
- [vite-plugin-transform](https://npm.io/package/vite-plugin-transform.md) — 2.4K weekly downloads

## Recent versions

- 2.2.0 (latest) — 2018-01-13
- 2.1.0 — 2017-05-26
- 2.0.2 — 2016-10-18
- 2.0.1 — 2016-10-18
- 2.0.0 — 2016-10-07
- 1.5.0 — 2016-09-01
- 1.4.0 — 2016-09-01
- 1.3.0 — 2016-08-11
- 1.2.0 — 2016-05-21
- 1.1.2 — 2016-01-26
- 1.1.1 — 2016-01-26
- 1.1.0 — 2016-01-25
- 1.0.0 — 2015-11-02
- 0.4.1 — 2015-10-13
- 0.4.0 — 2015-10-09
- … 11 more at https://npm.io/package/webpack-partial/versions

## README

# webpack-partial

Intelligently compose [webpack] configuration files.

![build status](http://img.shields.io/travis/webpack-config/webpack-partial/master.svg?style=flat)
![coverage](http://img.shields.io/coveralls/webpack-config/webpack-partial/master.svg?style=flat)
![license](http://img.shields.io/npm/l/webpack-partial.svg?style=flat)
![version](http://img.shields.io/npm/v/webpack-partial.svg?style=flat)
![downloads](http://img.shields.io/npm/dm/webpack-partial.svg?style=flat)


## Usage

```sh
npm install --save webpack-partial
```

Making [webpack] configurations composable is tricky. So we provide several helpers to ease the composition process. Each helper is of the form `(arg1, arg2, ..., webpackConfig)`. All functions are curried and the last argument is always a webpack configuration object allowing you to chain helpers together easily with `compose` (or `flow`).

Generally:

```javascript
import compose from 'lodash/fp/compose';
import plugin from 'webpack-partial/plugin';
import StatsWebpackPlugin from 'stats-webpack-plugin';
import ExtractTextWebpackPlugin from 'extract-text-webpack-plugin';

const buildConfig = compose(
  plugin(new StatsWebpackPlugin()),
  plugin(new ExtractTextWebpackPlugin())
);

const config = buildConfig({/* webpack config here */});
```

But you can also use them individually if you need to:

```javascript
import plugin from 'webpack-partial/plugin';
import StatsWebpackPlugin from 'stats-webpack-plugin';

const config = plugin(new StatsWebpackPlugin(), {/* webpack config here */});
```

The available helpers are:

 * entry
 * loader
 * output
 * plugin
 * tap

### entry(values, config)

Modify the webpack config `entry` object.

```javascript
// Set the `entry` to `index.js`
entry('index.js');

// Append `foo.js` to all existing entrypoints.
entry.append('foo.js');
entry((previous) => [...previous, 'foo.js'])
```

The `entry` function takes either a value to add to entry _or_ a function that maps the existing entry values to new ones. The values property is _always_ an array for consistency even though internally webpack can use objects, strings or arrays.

The callback has this signature:

```javascript
(previous: Array, key: ?String, config: Object) => { ... }
```

The `key` property represents the key in object-style entrypoints and `config` is the existing webpack configuration object.

### loader(loader, config)

Add a loader configuration to an existing webpack configuration.

```javascript
import loader from 'webpack-partial/loader';

const babel = loader({
  test: /\.js$/,
  loader: 'babel-loader',
})
babel(webpackConfig);
```

### output(object, config)

Merge the given output options into the output options in a webpack configuration. You can use it to do things like quickly change the `publicPath`.

```javascript
import output from 'webpack-partial/output';
const rebase = output({publicPath: '/somewhere'});
rebase(webpackConfig);
```

### plugin(object, config)

Append a plugin to the existing plugins in a webpack configuration.

```javascript
import plugin from 'webpack-partial/plugin';
import StatsWebpackPlugin from 'stats-webpack-plugin';

const stats = plugin(new StatsWebpackPlugin())
stats(webpackConfig);
```

### tap(func, config)

Observe the configuration but ignore any modifications. Can be useful to do things like dumping out a configuration.

```javascript
import tap from 'webpack-partial/tap';
const debug = tap((config) => console.log(config));
debug(webpackConfig);
```

[webpack]: http://webpack.github.io/

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