# laravel-mix-compress

> Laravel Mix extension for compressing assets with Brotli and Zopfli

Latest version **3.0.0** (published 2022-06-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install laravel-mix-compress
pnpm add laravel-mix-compress
yarn add laravel-mix-compress
bun add laravel-mix-compress
```

## 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 | 3.0.0 |
| Published | 2022-06-11 |
| First published | 2021-05-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 14.15.0 |
| Dependencies | 2 |
| Unpacked size | 6.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 7 |
| Author | Dmitry Seleznyov |
| Maintainers | selim13 |
| Keywords | laravel mix, mix, compress, brotli, zopfli |

## Links

- npm: https://www.npmjs.com/package/laravel-mix-compress
- Repository: https://github.com/selim13/laravel-mix-compress
- Issues: https://github.com/selim13/laravel-mix-compress/issues
- npm.io page: https://npm.io/package/laravel-mix-compress

## Dependencies (2)

- [@gfx/zopfli](https://npm.io/package/@gfx/zopfli.md) ^1.0.15
- [compression-webpack-plugin](https://npm.io/package/compression-webpack-plugin.md) ^10.0.0

## Alternatives

- [lodash.startswith](https://npm.io/package/lodash.startswith.md) — 769.7K weekly downloads
- [@tarojs/service](https://npm.io/package/@tarojs/service.md) — 33.9K weekly downloads
- [io.extendreality.tilia.indicators.spatialtargets.unity](https://npm.io/package/io.extendreality.tilia.indicators.spatialtargets.unity.md) — 131 weekly downloads
- [@rtarojs/taro](https://npm.io/package/@rtarojs/taro.md) — 90 weekly downloads
- [node-branch-io](https://npm.io/package/node-branch-io.md) — 50 weekly downloads

## Recent versions

- 3.0.0 (latest) — 2022-06-11
- 2.0.1 — 2021-11-19
- 2.0.0 — 2021-10-12
- 1.0.0 — 2021-05-16

## README

# Laravel Mix Compress Extension

Prepares Brotli and Zopfli compressed versions of assets using CompressionWebpackPlugin.

```
 Size Name
230Ki app.js
 55Ki app.js.br
 60Ki app.js.gz
839Ki app.js.map
175Ki app.js.map.br
194Ki app.js.map.gz
170Ki styles.css
 26Ki styles.css.br
 30Ki styles.css.gz
302Ki styles.css.map
 46Ki styles.css.map.br
 52Ki styles.css.map.gz
  634 sprite.svg
  285 sprite.svg.br
  313 sprite.svg.gz
```


## Install

```sh
npm install --save-dev laravel-mix-compress
```

or

```sh
yarn add -D laravel-mix-compress
```

## Usage

```js
// webpack.mix.js
const mix = require('laravel-mix');
require('laravel-mix-compress');

mix.js('src/app.js', 'js');
mix.css('src/app.css', 'css');
mix.compress();
```

### Options

You can pass some options too:
```js
mix.compress({
    productionOnly: false,
    minRatio: 1
});
```

- `productionOnly`: only compress assets on a production run i.e 
  on `mix --production`.
- `useBrotli`: generate Brotli compressed assets.
- `useZopfli`: generate Zopfli compressed assets.

Algorithm specific options:
- `brotliCompressionOptions`: [compression options](https://nodejs.org/api/zlib.html#zlib_class_brotlioptions)
  for Brotli.
- `zopfliCompressionOptions`: [compression options](https://github.com/gfx/universal-zopfli-js#options) 
  for Zopfli.

Common CompressionWebpackPlugin [options](https://webpack.js.org/plugins/compression-webpack-plugin/):

- `test`: include all assets that pass test assertion.\
  Default: `/\.(js|json|css|html|svg|map)(\?.*)?$/i`
- `include`: include all assets matching any of these conditions.
- `exclude`: exclude all assets matching any of these conditions.
- `threshold`: only assets bigger than this size are processed. In bytes.
- `minRatio`: only assets that compress better than this ratio are processed
- `deleteOriginalAssets`: whether to delete the original assets or not.


## Test

```sh
npm ci
npm test
```

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