How To Split Media Queries Under Webpack Config?
since we can import style sheets like below :
<link rel="stylesheet" media="screen and (min-width: 900px)" target="_blank" rel="nofollow noreferrer" href="widescreen.css">
<link rel="stylesheet" media="screen and (max-width: 600px)" target="_blank" rel="nofollow noreferrer" href="smallscreen.css">
and this will help faster loading of web site by loading only a css file which meets media
attribute conditions.MDN
I had no luck searching for webpack config that can split queries or at least let me manually specify which css entry should load on which media.
my only solution was to write nodejs script and inject index.html
at build time but that's not clean way to do it in my opinion.
so is there any webpack config for this kind of stuff?
Answer
This is more like a comment, but I believe there is a plugin for that:
https://github.com/SassNinja/media-query-plugin
Have you ever thought about extracting your media queries from your CSS so a mobile user doesn't have to load desktop specific CSS? If so this plugin is what you need!
Related Questions
- → How to update data attribute on Ajax complete
- → October CMS - Radio Button Ajax Click Twice in a Row Causes Content to disappear
- → Octobercms Component Unique id (Twig & Javascript)
- → Passing a JS var from AJAX response to Twig
- → Laravel {!! Form::open() !!} doesn't work within AngularJS
- → DropzoneJS & Laravel - Output form validation errors
- → Import statement and Babel
- → Uncaught TypeError: Cannot read property '__SECRET_DOM_DO_NOT_USE_OR_YOU_WILL_BE_FIRED' of undefined
- → React-router: Passing props to children
- → ListView.DataSource looping data for React Native
- → Can't test submit handler in React component
- → React + Flux - How to avoid global variable
- → Webpack, React & Babel, not rendering DOM