Skip to content

Commit 2f363dd

Browse files
committed
improve docs of media-query-plugin
I've now added filenames and line breaks in CSS code for better readability.
1 parent eb117d8 commit 2f363dd

File tree

1 file changed

+40
-8
lines changed

1 file changed

+40
-8
lines changed

README.md

Lines changed: 40 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -278,32 +278,64 @@ When writing CSS with the help of a framework (such as [Bootstrap](https://getbo
278278

279279
To improve this you can use the [media-query-plugin](https://github.com/SassNinja/media-query-plugin) which plays together well with the mini-css-extract-plugin. It will extract the defined media queries and emit them as separate files (or inject into existing chunks if working with dynamic imports).
280280

281-
Afterwards a mobile user only needs to load this
281+
Afterwards a mobile user needs to load initially
282282

283-
```scss
284-
.foo { color: red }
285-
.bar { font-size: 1rem }
283+
**`example.css`**
284+
```css
285+
.foo {
286+
color: red;
287+
}
288+
.bar {
289+
font-size: 1rem;
290+
}
286291
```
287292

288-
instead of this
293+
and only if necessary
289294

295+
**`example-desktop.css`**
290296
```css
291-
.foo { color: red }
292297
@media (min-width: 75em) {
293-
.foo { color: blue }
298+
.foo {
299+
color: blue;
300+
}
301+
}
302+
```
303+
304+
instead of always the full
305+
306+
**`example.css`**
307+
```css
308+
.foo {
309+
color: red;
310+
}
311+
@media (min-width: 75em) {
312+
.foo {
313+
color: blue;
314+
}
315+
}
316+
.bar {
317+
font-size: 1rem;
294318
}
295-
.bar { font-size: 1rem }
296319
```
297320

298321
#### Usage
299322

300323
Using the media-query-plugin is quite easy. Add the included loader to your rules and the plugin to your plugins. It will take over the filename option of the mini-css-extract-plugin and recognize its generated CSS chunks.
301324

325+
**`example.js`**
326+
```javascript
327+
import './example.scss';
328+
```
329+
330+
**`webpack.config.js`**
302331
```javascript
303332
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
304333
const MediaQueryPlugin = require('media-query-plugin');
305334

306335
module.exports = {
336+
entry: {
337+
example: './example.js'
338+
},
307339
module: {
308340
rules: [
309341
{

0 commit comments

Comments
 (0)