You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+62Lines changed: 62 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -272,6 +272,68 @@ module.exports = {
272
272
273
273
For long term caching use `filename: "[contenthash].css"`. Optionally add `[name]`.
274
274
275
+
### Media Query
276
+
277
+
When writing CSS with the help of a framework (such as [Bootstrap](https://getbootstrap.com/) or [Foundation](https://foundation.zurb.com/sites.html)) and with a modular design pattern your emited CSS files will probably contain many media queries. This is quite bad for mobile users who have to load all desktop specific CSS which they will never need.
278
+
279
+
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).
280
+
281
+
Afterwards a mobile user only needs to load this
282
+
283
+
```scss
284
+
.foo { color: red }
285
+
.bar { font-size: 1rem }
286
+
```
287
+
288
+
instead of this
289
+
290
+
```css
291
+
.foo { color: red }
292
+
@media (min-width: 75em) {
293
+
.foo { color: blue }
294
+
}
295
+
.bar { font-size: 1rem }
296
+
```
297
+
298
+
#### Usage
299
+
300
+
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.
For more information please check the media-query-plugin [docs](https://github.com/SassNinja/media-query-plugin) and [examples](https://github.com/SassNinja/media-query-plugin/tree/master/examples).
0 commit comments