# laravel-mix-extract-media-queries

> A Laravel Mix extension for @elambro/extract-css-media-queries

Latest version **6.1.0** (published 2021-05-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install laravel-mix-extract-media-queries
pnpm add laravel-mix-extract-media-queries
yarn add laravel-mix-extract-media-queries
bun add laravel-mix-extract-media-queries
```

## 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 | 6.1.0 |
| Published | 2021-05-24 |
| First published | 2020-09-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 6.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Erin Lambroschini |
| Maintainers | elambro |

## Links

- npm: https://www.npmjs.com/package/laravel-mix-extract-media-queries
- Repository: https://github.com/elambro/laravel-mix-extract-media-queries
- Homepage: https://github.com/elambro/laravel-mix-extract-media-queries#readme
- Issues: https://github.com/elambro/laravel-mix-extract-media-queries/issues
- npm.io page: https://npm.io/package/laravel-mix-extract-media-queries

## Dependencies (1)

- [@elambro/extract-css-media-queries](https://npm.io/package/@elambro/extract-css-media-queries.md) ^1.0.0

## Recent versions

- 6.1.0 (latest) — 2021-05-24
- 6.0.0 — 2021-05-11
- 1.0.3 — 2020-12-14
- 1.0.2 — 2020-09-07
- 1.0.1 — 2020-09-07
- 1.0.0 — 2020-09-07

## README

# Laravel Mix Extract Media Queries

[![npm version](https://badge.fury.io/js/laravel-mix-extract-media-queries.svg)](https://badge.fury.io/js/laravel-mix-extract-media-queries) [![GitHub version](https://badge.fury.io/gh/elambro%2Flaravel-mix-extract-media-queries.svg)](https://badge.fury.io/gh/elambro%2Flaravel-mix-extract-media-queries) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg)](https://github.com/elambro/laravel-mix-extract-media-queries/graphs/commit-activity)

A Laravel Mix Extension for [https://github.com/elambro/extract-css-media-queries].
This package extracts media queries (e.g. `@media (min-size: 768px) {...}`) from your CSS into separate stylesheets which you can use to lower package sizes for your mobile users.

You can then load this larger stylesheet(s) through a `<link>` tag:

```html
<link rel="stylesheet" media="screen and (min-width: 768px)" href="/style.css">
```
or load it dynamically through your js.

## Installation

```
npm i -D laravel-mix-extract-media-queries
```

## Usage

```js

require('laravel-mix-extract-media-queries');

//...

mix.extractMediaQueries({
    hash: '[name].[contenthash].css',
    breakpoints: [{
        minWidth: 768,
        verbose : false,
        minify  : mix.inProduction(),
        combined: true,
        filename: `css/large.css`,
    }]
});

```
This will extract all media queries with a min-width greater or equal to 768 and extract them to the `css/large.css` file

## Examples

1.

`const options = {breakpoints:[567,767]}`

Will give you 3 files:
-  `style.css`       - Common style, with all media queries `@media (min-width: 567px)` and higher extracted out.
- `style-767.css`  - Only media queries `@media(min-width: 767px)` and above. e.g. `@media(min-width: 800px)` is also included.
- `style-567.css` -  Only media queries `@media(min-width: 567px)` up to `@media(min-width: 767px)`

Duplicate media queries are merged in the results, then they're sorted with the highest `min-width` (and `min-height`) media queries at the bottom of the file.

2.

```js
{
    groups: [
        {
            breakpoints:[
                {
                    minWidth: 640,
                    filename: 'css/utilities-sm.[ext]',
                },
                {
                    minWidth: 768,
                    filename: 'css/utilities-md.[ext]',
                },
                {
                    minWidth: 1024,
                    filename: 'css/utilities-lg.[ext]',
                },
                {
                    minWidth: 1280,
                    filename: 'css/utilities-xl.[ext]',
                },
                {
                    minWidth: 1500,
                    filename: 'css/utilities-2xl.[ext]',
                },
            ],
            include : '/css/utilities.css',
            combined : false,
            verbose : true,
            minify  : mix.inProduction(),
        },
    ]
}
```js

## Webpack

For options, see the webpack plugin [https://github.com/elambro/extract-css-media-queries]

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