# @brillout/webpack-config-mod

Latest version **0.5.13** (published 2020-11-12) · 0 weekly downloads

## Install

```sh
npm install @brillout/webpack-config-mod
pnpm add @brillout/webpack-config-mod
yarn add @brillout/webpack-config-mod
bun add @brillout/webpack-config-mod
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.5.13 |
| Published | 2020-11-12 |
| First published | 2018-04-30 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 24.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 57 |
| Maintainers | brillout |

## Links

- npm: https://www.npmjs.com/package/@brillout/webpack-config-mod
- Repository: https://github.com/reframejs/goldpage
- Homepage: https://github.com/reframejs/goldpage#readme
- Issues: https://github.com/reframejs/goldpage/issues
- npm.io page: https://npm.io/package/@brillout/webpack-config-mod

## Dependencies (2)

- [reassert](https://npm.io/package/reassert.md) ^1.1.12
- [lodash.escaperegexp](https://npm.io/package/lodash.escaperegexp.md) ^4.1.2

## Recent versions

- 0.5.13 (latest) — 2020-11-12
- 0.5.12 — 2020-11-12
- 0.5.11 — 2020-10-13
- 0.5.10 — 2020-10-01
- 0.5.9 — 2020-09-27
- 0.5.8 — 2020-09-17
- 0.5.7 — 2020-07-22
- 0.5.6 — 2020-03-22
- 0.5.5 — 2019-10-14
- 0.5.4 — 2019-10-03
- 0.5.3 — 2019-10-02
- 0.5.2 — 2019-09-14
- 0.5.1 — 2019-09-09
- 0.5.0 — 2019-09-08
- 0.4.0 — 2019-07-31
- … 25 more at https://npm.io/package/@brillout/webpack-config-mod/versions

## README

<!---






    WARNING, READ THIS.
    This is a computed file. Do not edit.
    Instead, edit `/helpers/webpack-config-mod/readme.template.md` and run `npm run docs` (or `yarn docs`).












    WARNING, READ THIS.
    This is a computed file. Do not edit.
    Instead, edit `/helpers/webpack-config-mod/readme.template.md` and run `npm run docs` (or `yarn docs`).












    WARNING, READ THIS.
    This is a computed file. Do not edit.
    Instead, edit `/helpers/webpack-config-mod/readme.template.md` and run `npm run docs` (or `yarn docs`).












    WARNING, READ THIS.
    This is a computed file. Do not edit.
    Instead, edit `/helpers/webpack-config-mod/readme.template.md` and run `npm run docs` (or `yarn docs`).












    WARNING, READ THIS.
    This is a computed file. Do not edit.
    Instead, edit `/helpers/webpack-config-mod/readme.template.md` and run `npm run docs` (or `yarn docs`).






-->

## `@brillout/webpack-config-mod`

Webpack config modifiers.

##### Contents

 - [Usage Example](#usage-example)
 - [API](#api)


### Usage Example

~~~js
// ./example.js

const mod = require('@brillout/webpack-config-mod'); // npm install @brillout/webpack-config-mod

const assert = require('reassert');
const path = require('path');

const config = {
    entry: './path/to/entry-file.js',
    output: {
        path: path.resolve(__dirname, 'dist'),
        filename: 'my-first-webpack.bundle.js'
    },
    module: {
        rules: [
            {
                test: /\.js$/,
                exclude: /node_modules/,
                use: [
                    {
                        loader: 'babel-loader',
                        options: {
                            presets: ['@babel/preset-env']
                        }
                    }
                ]
            }
        ]
    }
};

mod.setRule(config, '.css', {use: ['style-loader', 'css-loader']});
mod.addBabelPreset(config, '@babel/preset-react');
mod.addBabelPlugin(config, '@babel/plugin-proposal-decorators');

const jsRule = mod.getRule(config, '.js');
const babelLoader = jsRule.use.find(({loader}) => loader==='babel-loader');
assert(babelLoader.options.presets.includes('@babel/preset-env'));
assert(babelLoader.options.presets.find(preset => preset[0]==='@babel/preset-react'));
assert(babelLoader.options.plugins.find(preset => preset[0]==='@babel/plugin-proposal-decorators'));

const entries = mod.getEntries(config);
assert(entries['main'][0] === './path/to/entry-file.js');

console.log("Success");
~~~

### API

 - `setRule(config, filenameExtension, newRule)`
   <br/>
   Add or modify the rule that matches file names ending with `filenameExtension`.

 - `getRule(config, filenameExtension, {canBeMissing=false}={})`
   <br/>
   Get the rule that matches file names ending with `filenameExtension`.

 - `getEntries(config)`
   <br/>
   Get all the entries of `config`.

 - `addBabelPlugin(config, babelPlugin)`
   <br/>
   Add a babel plugin to all `babel-loader` loaders' options object.

 - `addBabelPreset(config, babelPreset)`
   <br/>
   Add a babel preset to all `babel-loader` loaders' options object.

 - `modifyBabelOptions(config, action)`
   <br/>
   Apply the `action` function to all `babel-loader` loaders' options object.

 - `addExtension(config, extension)`
   <br/>
   Add `extension` to `config.resolve.extensions` (only if missing).

<!---






    WARNING, READ THIS.
    This is a computed file. Do not edit.
    Instead, edit `/helpers/webpack-config-mod/readme.template.md` and run `npm run docs` (or `yarn docs`).












    WARNING, READ THIS.
    This is a computed file. Do not edit.
    Instead, edit `/helpers/webpack-config-mod/readme.template.md` and run `npm run docs` (or `yarn docs`).












    WARNING, READ THIS.
    This is a computed file. Do not edit.
    Instead, edit `/helpers/webpack-config-mod/readme.template.md` and run `npm run docs` (or `yarn docs`).












    WARNING, READ THIS.
    This is a computed file. Do not edit.
    Instead, edit `/helpers/webpack-config-mod/readme.template.md` and run `npm run docs` (or `yarn docs`).












    WARNING, READ THIS.
    This is a computed file. Do not edit.
    Instead, edit `/helpers/webpack-config-mod/readme.template.md` and run `npm run docs` (or `yarn docs`).






-->

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