# @webpackon/use-optimization

> Webpackon use optimization

Latest version **1.0.2** (published 2022-11-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install @webpackon/use-optimization
pnpm add @webpackon/use-optimization
yarn add @webpackon/use-optimization
bun add @webpackon/use-optimization
```

## Health

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

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2022-11-01 |
| First published | 2021-12-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 9.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | AndTem |
| Maintainers | and_tem |
| Keywords | webpackon, webpack, webpack 5, webpack config, webpack-config, use optimization, webpackon optimization |

## Links

- npm: https://www.npmjs.com/package/@webpackon/use-optimization
- Repository: https://github.com/AndTem/webpackon
- Homepage: https://github.com/AndTem/webpackon/tree/master/packages/optimization#Readme
- Issues: https://github.com/AndTem/webpackon/issues
- npm.io page: https://npm.io/package/@webpackon/use-optimization

## Dependencies (3)

- [@webpackon/core](https://npm.io/package/@webpackon/core.md) ^1.1.6
- [terser-webpack-plugin](https://npm.io/package/terser-webpack-plugin.md) ^5.1.4
- [case-sensitive-paths-webpack-plugin](https://npm.io/package/case-sensitive-paths-webpack-plugin.md) ^2.4.0

## Alternatives

- [jsforce](https://npm.io/package/jsforce.md) — 851.2K weekly downloads
- [react-native-qrcode-svg](https://npm.io/package/react-native-qrcode-svg.md) — 693.5K weekly downloads
- [@salesforce/plugin-data](https://npm.io/package/@salesforce/plugin-data.md) — 394.9K weekly downloads
- [@backstage/plugin-search-common](https://npm.io/package/@backstage/plugin-search-common.md) — 308.5K weekly downloads
- [@chain-registry/types](https://npm.io/package/@chain-registry/types.md) — 38.4K weekly downloads

## Recent versions

- 1.0.2 (latest) — 2022-11-01
- 1.0.1 — 2022-01-25
- 1.0.0 — 2021-12-08

## README

<p align="center">
  <img src='https://raw.githubusercontent.com/AndTem/webpackon/master/images/logo.svg' height='120' width='120'>
</p>
<p align="center">
  <a href="https://github.com/AndTem/webpackon#readme">Webpackon</a>
</p>

# @webpackon/use-optimization

Features:
- minification js for production
- enable split chunks
- optimizing chunks ids
- adds hash for result files
- adds hash for assets, places their in the ```static``` directory
- cleaning dist directory before build
- generates hidden source map files

## Install
```shell
npm i @webpackon/use-optimization --save
```

```shell
yarn add @webpackon/use-optimization
```

## API

```ts
const { useOptimization } = require('@webpackon/use-optimization');

useOptimization(params: UseOptimizationParams)(config: WebpackConfig)
```

### UseOptimizationParams
```ts
type UseOptimizationParams = {
  mode: 'development' | 'production';
  dropConsole?: boolean;
  splitChunkCacheGroups?: Array<{
    chunkName: string;
    includePackages: string[];
  }>;
};
```

- ```mode``` - webpack mode

- ```dropConsole``` - removes console for production (default - ```true```)

- ```splitChunkCacheGroups``` - packages (includePackages) that will be combined into one chunk (chunkName)

## Example
Full examples are [here](https://github.com/AndTem/webpackon/tree/master/examples)

```js
const path = require('path');

const { compose } = require('@webpackon/core');
const { useOptimization } = require('@webpackon/use-optimization');

module.exports = (_, { mode }) =>
  compose(
    useOptimization({
      mode,
      splitChunkCacheGroups: [
        { chunkName: 'react', includePackages: ['react', 'react-dom'] },
      ],
    })
  )({
    target: 'web',
    entry: path.resolve(__dirname, 'src', 'index.tsx'),
  });
```

Result:
<img src='https://raw.githubusercontent.com/AndTem/webpackon/master/images/react-example-result.png'>

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